I am new to python and socket programming, and I'm confused about about usage for socket.recvfrom()
and socket.recv()
. I understand that people usually use recvfrom()
for UDP and recv()
for TCP.
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 do these numbers represent?
recv
says max of buffsize bytes, butrecvfrom
it doesn't mention bytes. – Open