I'm just curious about how the server knows if the received segment is a UDP or a TCP segment, especially when the listening port can listen on both UDP and TCP.
I know the client can use SOCK_DGRAM
to generate UDP segments and SOCK_STREAM
for TCP segments, but the segment transmitted is still a bunch of bits. How can the server know whether it should interpret these bits as a UDP segment or as a TCP segment? What if these bits are a UDP segment, but accidentally do not mean "too weird" if they are interpreted as a TCP segment?