i am new to python and new to socket programming as well.
I am confused about about socket.recvfrom()
and socket.recv()
I understand that usually for UDP, people use recvfrom()
and for TCP, people use recv()
.
For example,
serverSocketUDP = socket(AF_INET, SOCK_DGRAM)
serverSocketTCP = socket(AF_INET, SOCK_STREAM)
#... define server...
#...
message, clientAddress = serverSocketUDP.recvfrom(2048) #why 2048 for UDP? Ive seen several examples like this.
message2 = serverSocketTCP.recv(1024) #Again, why 1024 for TCP?
As seen in the example above, what i am confused about is the numbers. Why 2048 and 1024 for different protocols? What does these numbers represent? Please explain. I hope i was clear enough. Thank you.
recv
says max of buffsize bytes, butrecvfrom
it doesn't mention bytes. – Craig Hicks