Download Experiment Manual
Transcript
Experiment 13: TCP/IP Sockets Write Using TCP/IP sockets, write a client – server program to make the client send the file name and to make the server send back the contents of the requested file if present Theory: The socket is a fundamental concept to the operation of TCP/IP application software. It is also an interface between the application and the network. The exchange of data between a pair of devices consists of a series of messages sent from a socket on one device to a socket on other. Once the socket is configured, the application can send the data using sockets for network transmission and receive the data using sockets from the other host. A socket communication can be connection oriented (TCP sockets) or connectionless (UDP sockets). There is a receiver (TCP) server, which listens to the sender (TCP) client communications. There can be two-way communication. Algorithm: Create a socket using address family (AF_INET), type (SOCK_STREM) and protocol (TCP) Initialize the address family, port no and IP address to communicate using sockets Bind a local address and port number with a socket Listen for an incoming socket connection Accept an incoming connection attempt on a socket Receive an incoming message Write that incoming message to Output.txt Send ACK to received socket 108