11-04-2014, 02:27 PM
DATE-TIME SERVER
AIM
To write a C program for implementing the simple TCP client-server where the server acts as a Date-Time server.
ALGORITHM
SERVER
Step 1 :Start the program
Step 2 :Create an unnamed socket for the server using parameters AF_INET as
domain and SOCK_STREAM as type.
Step 3 : Declare the time variables t.
Step 4 :Get the server port number.
Step 5 :Register the host address to the system by using bind() system call in server
side.
Step 6 :Create a connection queue and wait for clients using listen() system call with
The number of clients requests as parameter.
Step 7 :Accept the connection using accept( ) system call when the client
request for connection.
Step 8 :Stop the Program execution.
CLIENT
Step 1 :Start the program.
Step 2 :Create an unnamed socket for the client using parameters AF_INET as
domain and SOCK_STREAM as type.
Step 3 :Get the client port number.
Step 4 :Now connect the socket to server using connect( ) system call.
Step 5 :The recv() system call gets the response of Date-Time request from the
server.
Step 6 rint the date and time
Step 7 :Stop the program.
RESULT
Thus the C program for printing Date and time is executed and the output is verified successfully