PS 6: Last problem set for CS149 @SJSU

Our instructions: 

  • The purpose of this assignment is to practice making multiple concurrent Linux I/O system calls in C, with a server process listening to multiple sockets and multiple clients communicating with the server process over the sockets.

    Server

    Create three sockets (local communication sockets), named as “CS149-Socket1”, “CS149-Socket2”, and “CS149-Socket3”. It must use the select() system call to determine whether any of the sockets has received connection request and/or any input data. The select() call is necessary so that request/data on any socket(s) can unblock the server. Once data is received from a socket, it first writes back to the client “received from socket ID:” , following by the content received. The “socket ID” should be replaced with the actual socket name (server socket name) from which the data is received. Then it should print out the same content on screen as well as to an output file “server-output.txt”. The server repeats the process of listening/reading/printing/writing with an infinite loop until terminated by user (via Control-C).

    Clients

    Create three client programs (namely Client 1, Client 2, and Client 3). Each client can start/terminate independently and should connect with the server via one of the three sockets created by the server respectively, i.e., Client 1 connects to socket “CS149-Socket1”, Client 2 connects to socket “CS149-Socket2”, and Client 3 connects to socket “CS149-Socket3”. Each client will ask user to type in a string and then write the string, appended by the client ID, to the corresponding socket. For example, if user input string to Client 1 is “CS149 class is great!”,

    then Client 1 should write the string “Client 1 user message: CS149 class is great!” to the socket “CS149-Socket1”. The client should also write the same string to a file “client1.txt”. Then the client should wait for the response from the server. Once the response is received, it should print out “Server response received:”, following by the content received. It also should write this to the output file “client1.txt” and repeat the process (waiting for user to input the next string, etc) until terminated by user (via Control-C).

    ————————————————————————————————————————————————

    Let the fun begin.

    Ok so first off this has to be coded in C. I haven’t coded in C for quite a while so time to do some reading.

    The professor added a number of src files that show which each individual thing does. That is he has the Client, Socket, and Server src files. I am guessing I am going to see how each portion works and build a program that has all 3 components….. In Java this would be easy since I know the language pretty well. Doing this in C though is going to take some time.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s