Información

Autor(es) Maxime Piraux
Fecha de entrega 28/02/2024 23:59:59
Tiempo límite de envío Sin límite de envío

Inicia sesión

Sockets - Sending strings

In this exercise, you will built upon the small server you just implemented to add new functionalities.

So far your server, i.e. the code that receive the message and performs the sum, sent back the result as network-ordered unsigned integers. In this task you have to change the format of the result. Instead of using network-ordered unsigned integers, the result must be encoded as a string. Use the sprintf() call to achieve this.

For each of the calls that you use, if one of them were to encounter an error, immediately return -1. All require headers are already included.

Manpages of interest:


Sending strings through sockets

Copy the function signature and fill in its body

int recv_and_handle_message(const struct sockaddr *src_addr, socklen_t addrlen) {
    // TODO: Create a IPv6 socket supporting datagrams
    // TODO: Bind it to the source
    // TODO: Receive a message through the socket
    // TODO: Perform the computation
    // TODO: Send back the result
    return 0;
}