Our CS department has recently acquired various supercomputers with various architecture. Given their processing power, the department would like to make them available as a cloud computing platform, where the researchers and students would send computationally-intensive tasks.
To use these computers, you need to design a first version of a simple client-server application. This first version will allow a client to send a vector of 32-bits integers and receive their sum from the server.
We first use UDP to allow the client to send a request to the server. In this case, the client must send the vector of integers in a single datagram and the server responds with a single datagram too. In theory, UDP supports datagrams that can be as large as 64 KBytes. In practice, most implementations restrict this maximum size even more. We use the MAX_SIZE constant, which is currently set to 16000 to represent this maximum datagram size.
We ask you to complete the client and the server functions. These two functions are tested separately, so you will get partial points and partial results for each of them.
A few hints to help you:
- Recall that UDP sends datagrams and is connectionless.
- Remeber that there is a difference between the representation of integers on a host and its representation in the network. The C library contains macros to help you deal with these differences.
- Don't forget to release all the memory that you have allocated with malloc
- Your code needs to support both IPv4 and IPv6. It doesn't require a lot of adaptation (only one line in one function).
You may also need to read the manpages for the following calls: recv, recvfrom, send, sendto, close, htonl, bind and connect.