Source: https://lig-membres.imag.fr/genoud/ENSJAVA/cours/supportsPDF/sockets_2pp.pdf