Task 3
Task 3
Task 3
Summary:
Your CIO assigns you another project which involves setting up of connections between many clients and one
server.
Task 1 - First of all, write a program that facilitates one client communicating with the server, in separate windows.
Task 2 - Secondly, while the first client is running, start 10 other clients that connect to the same server; these
clients should most likely be started in the background with their input redirected from a file. Report what happens
to these 10 clients? Do their connect()s fail, or time out, or succeed? Do any other calls block? Now let the client
exit. Explain what happens.
Task 3 - Thirdly, modify the socket program so that each time the client sends a line to the server, the server sends
the line back to the client. The client (and server) will now have to make alternating calls recv () and send ().
Task 4 - Finally, modify the socket program so that it uses UDP as the transport protocol, rather than TCP. You will
have to change SOCK_STREAM to SOCK_DGRAM in both the client and the server. Discuss what happens when two
UDP clients simultaneously connect to the same UDP server and compare this to the TCP behaviour.
Socket Tasks:
Task 2 - Secondly, while the first client is running, start 10 other clients that connect to the same server; these
clients should most likely be started in the background with their input redirected from a file. Report what happens
to these 10 clients? Do their connect()s fail, or time out, or succeed? Do any other calls block? Now let the client
exit. Explain what happens.
Task 3 - Thirdly, modify the socket program so that each time the client sends a line to the server, the server sends
the line back to the client. The client (and server) will now have to make alternating calls recv () and send ().
Client communication
Client communicates
with the server,
displaying the client
number.
Server communication
The client sends a string
to the server, which
accepts it and returns
the string to the client
with an ID number.
Screen Output continues When the client closes, the server returns an error code.
The server can handle ten simultaneous connections. We used a loop to create all connections and because of
this the client programme cannot close one connection.
Task 4 - Finally, modify the socket program so that it uses UDP as the transport protocol, rather than TCP. You will
have to change SOCK_STREAM to SOCK_DGRAM in both the client and the server. Discuss what happens when two
UDP clients simultaneously connect to the same UDP server and compare this to the TCP behaviour.
Screen Output
Figure: Server started
with UDP connection.
Client Response
Figure: Client response
with ID number, Client
IP and port address.
Figure: Server
response:
Discuss what happens when two UDP clients simultaneously connect to the same UDP server and compare this to
the TCP behaviour.
They consume too much time and cause CPU overload
TCP connections were much easier to set up
The data is presented as a byte array
Conclusion:
While doing the assessments, users will learn intermediate-level python socket program and in-
depth cloud computing uses.