Free Tutorials, Linux Command, Source Code Architecture,  Software Engineering, Intelligent Systems, RDBMS, Computer Accounting,  Operations Research, Discrete Mathematics, Network, SAD Lay Networks Lay Networks
Computer Science Networking Operating Systems Linux and Unix Source Code Script & Languages Protocols Glossary
Web laynetworks.com
Google
 

Example of using BSD sockets: "Echo Server"

Design
This program implements a simple client-server program. The client connects to the server via TCP and sends it any ASCII text message. The server replies to the client with the same message. The client then outputs the message the server returned.

The message sent from the client to the server consists of two parts. The first byte sent contains the length of the message, not including itself. The rest of the message is the message to be repeated back from the server to the client. The reply message is in the same format. The length is passed in order to allow the server to be sure it has read all available data. Compiling

To compile this program, go to any Solaris machine. Copy the following files to any subdirectory in your Unix home directory:

  • Makefile
  • client.c
  • server.c
  • common.h
  • Test

    Type "make" in the directory where the source code is located. Two binaries should be produced: "client" and "server". Telnet to another machine. Run "server" on one machine and "client" on the other machine.

Usage

Server: The server is started with a single command line argument, the port number. The server will wait on this port until contact is made by the client. Once the server replies to the message sent by the client, it exits.
Example: #server 2000 (note: the pound sign indicates the Unix prompt)

Client:
The client is started with three command line arguments. These arguments include the host, port number, and message to send. The client will then send the given message to the given host and port number and wait for a reply. Once the reply is recieved, the client exits.
Example:#client ece2.ece 2000 "This is a test of the emergency broadcast system"

Design Tradeoffs

The program is limited to transmitting a message containing 255 characters. This could be improved by seperating the message into smaller chunks. The server will continue to receive the chunks until all has been sent. This could be done with minimal modification of code. All the is needed is some sort of "all done" message sent between the client and server.

NOTE: There is a quick script called "Test" that will run a simple test case.

Back
FDDI Frequently Asked Questions (FAQ), The function and frame format of FDDI,Aloha,Comparative analysis between two types of ATM Switches,Knockout Switch,Barcher-Banyan Switch,Various popular standards for compressing multimedia data,Distributed Multimedia Survey: Standards, ASCII to hex value chart,Comparative analysis - TCP - UDP, Addressing Formats and QoS parameters, Bellman Ford's Algorithm Lay networks, free, java, java script, asp, vb, linux, ignou, tutorial, Unix commands, System Analysis, System Design, Ipv6, quiz, download, free, Computer Architecture, Object Oriented System, Relational Database Management Systems, Object Oriented System, Operating Systems, Software Engineering, Communications and Networks, Discrete Mathematics, Intelligent Systems, Operations Research, Accounting and Finance on Computersmca, networking, protocols, glossary, assignment, project, tma, programming source code, programming, source code, unix, free
 
Book Mark/Share this site at BlinkBits BlinkList Blogmarks co.mments Delicious Digg Fark Furl it! Google Ma.gnolia Netvouz NewsVine RawSugar Reddit Shadows Simpy Stumble Technorati YahooMyWeb

Copyright © 2000- 2007 Lay Networks All rights reserved. 
This website is best viewed in Firefox 1.0.1 above.

Web Hosting sponsored by Customized Software Company India
Web Site Designed by Web Designing, Flash Animation, Multimedia Presentations, Broacher/catalogue designing, Web Promotion 
Refer to your freind About Us Legal IGNOU Contact Us Feedback Donate to laynetworks.com Download Management Tutorials Tutorials History Search here