









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










โ (^) In this lab, we will create two programs which communicate using the client / server model. โ (^) In this model, the server establishes a handshake socket with a particular address. Client programs create a session socket , which attempts to connect to the handshake socket. When the handshake socket receives a request to connect, the server accepts the connection and creates another session socket which is connected to the client's session socket. These session sockets can be used to exchange data between the client and server processes. Client 1 Client 2 HS Socket SS1 SS Client 1 SS Client 2 SS Connect Connect Server Accept Connected Session 1 Connected Session 2
โ (^) Unix sockets are addressed by creating a file on the file system which socket endpoints refer to.
โ (^) Now that we have the socket bound to an address, we need to tell the operating system that this socket is a handshake socket (i.e. one that does not transfer data, but only listens for sockets trying to connect). โ (^) This is performed with the listen system call:
โ (^) At this point, each the client and the server should have access to a file descriptor that points to a connected socket endpoint. โ (^) In this lab, we will use these sockets to implement a server which performs uppercase string conversion. The client will send several strings to the server, the server will convert these strings to uppercase, and then send the converted strings back to the client. This is very similar to what you will do in the first class project. โ (^) I have predefined an array of strings to pass at the top of client.c.
โ (^) When you are done, uncomment the printf statements in each the client and the server. When you run both the client and the server (note you should always start the server first), your output should look like this: -bash-3.2$ ./server RECEIVED: this is the first string from the client SENDING: THIS IS THE FIRST STRING FROM THE CLIENT RECEIVED: this is the second string from the client SENDING: THIS IS THE SECOND STRING FROM THE CLIENT RECEIVED: this is the third string from the client SENDING: THIS IS THE THIRD STRING FROM THE CLIENT -bash-3.2$ ./client SENDING: this is the first string from the client RECEIVED: THIS IS THE FIRST STRING FROM THE CLIENT SENDING: this is the second string from the client RECEIVED: THIS IS THE SECOND STRING FROM THE CLIENT SENDING: this is the third string from the client RECEIVED: THIS IS THE THIRD STRING FROM THE CLIENT