Informasjon

Forfatter(e) Vany Ingenzi
Frist Ingen frist
Innleveringsgrense Ingen begrensning

Merkelapper

Logg inn

[Python] 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.

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.

Documentation of interest:


Copy the function signature and fill in its body

def recv_and_handle_message(bind_addr: str, bind_port: int) -> int:
    # 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 formatted result
    return 0