2 programs related to TCP-UDP Socket/Network Programming
₹600-1500 INR
Closed
Posted over 9 years ago
₹600-1500 INR
Paid on delivery
===============================================================
Important to Note:
1.Pls. don’t use temporary files and system() function.
2. Only working programs will be evaluated. If there are compilation errors, it will not be evaluated.
3. Pls. provide makefile for each problem.
===============================================================
Question1. Write a pre-forking TCP server chatserver.c that works in the following way. It takes port number, and N on command line. It pre-forks N children. That means at a time N clients can be handled. Each child waits on accept() call and accepts connections. When it receives a message from client, it should send the message to all other clients which are connected to the server. Child should also print to console "<pid> received <msg> from <client ip>:<client port>". A client ("web browser") sends a message in the URL itself. E.g.: Say chat server is running at port 9000. In the browser one types http://localhost:9000/?msg=hi all. Server should send the message "hi all" to all other clients which are connected to it. Since server has to interact with the browsers, replies should in HTTP Response format. Use message queues for inter process communication.
Question2. Write a UDP server gameserver.c that works in the following way. It takes P, nextP, nextIP, and start values on the command-line. It binds its socket to port number P. When it receives an integer N on the socket, it reduces it by 1 and sends it to the next destination represented by nextIP and nextP. Server should print "<pid> received N and sent N-1". When a server receives 0, it will send K (a random integer) to the next destination and print "Out from the game". When a server is out from the game, it doesn't reduce the incoming integer but rather forward it as it is to the next destination. A server that remain till end is the winner.
E.g: A three server game. server1, server2 and srever3 are all executables of gameserver.c.
./server1 9000 [login to view URL] 9001 0
./servar2 9001 [login to view URL] 9002 0
./server3 9002 [login to view URL] 9000 1
Here server3 is the starting server. It will chose a random integer K and send it to the next destination.
How to send me?
Make a directory for each problem like P1, P2 etc and copy your source files into these directories.
Tar all of them into [login to view URL]
Wed, 22 Oct 2014 12:26:04 +0530
Forked servers from TCP server will all be tcp-servers. How does UDP server relate to TCP-server?
What is start value ( in UDP server for? Is it children forked (like in tcp server)?
What is the compiler and version?
Any default CFLAGS?
Any compile option configuration required -- static | shared?