socket.AF_INET
or socket.AF_INET6
for family and socket.SOCK_STREAM
for type.AF_INET
is ipv4 and AF_INET6
is ipv6. You can also use families as AF_UNIX
, AF_IPX
, AF_IRDA
and AF_BLUETOOTH
, for example.SOCK_STREAM
stands for TCP socket and SOCK_DGRAM
for UDP socket. There are also another possibilities but these two will be enough for 99% of the times.s
) that has the following main methods:localhost
and port 9999
and sets it to listen for incoming connections, that means that every application in your pc that tries to communicate with your localhost at port 9999 will "talk" with this socket. When this application connects itself to the socket, the server will generate a connection and the address of the client, or in this case, the application.recv
) batches of 1024 bytes (note that this doesn't mean that the client will need to send 1024 bytes).send
internally until all the data is sent.accept()
in the cycle.s
.localhost
and port 9999
, sending the message Hello world!
using sendall
, already mentioned.Received
, together with the repr
esentation as a string of the data received.