O
O.B.
I have two sockets:
Socket tcpSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
Socket udpSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);
The BeginReceiveFrom operation is invoked with a buffer of 1500 bytes
(the MTU size). Example:
byte[] buffer = new byte[1500];
udpSocket.BeginReceive(buffer, 0, 1500, SocketFlags.None,
new AsyncCallback(ReceiveDataCallback), null);
When configuring a C# Socket class as a TCP socket, I have noticed
that each time the BeginReceiveFrom operation is invoked, it will
stuff as much data as possible into the specified "buffer." However,
when it is configured as a UDP socket, it only puts one packet into
the "buffer" each time the operation is invoked ... regardless of if
the "available" buffer if full.
So this brings about many questions.
First, when I send 1000 packets that are 144 bytes long through the
UDP socket, is 144,000 bytes sent? Or are 144 * 1500 (MTU Size) bytes
sent?
If only 144,000 bytes are sent, why does the BeginReceiveFrom
operation only populate one packet into the buffer per call to the
BeginReceiveFrom operation?
Socket tcpSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
Socket udpSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);
The BeginReceiveFrom operation is invoked with a buffer of 1500 bytes
(the MTU size). Example:
byte[] buffer = new byte[1500];
udpSocket.BeginReceive(buffer, 0, 1500, SocketFlags.None,
new AsyncCallback(ReceiveDataCallback), null);
When configuring a C# Socket class as a TCP socket, I have noticed
that each time the BeginReceiveFrom operation is invoked, it will
stuff as much data as possible into the specified "buffer." However,
when it is configured as a UDP socket, it only puts one packet into
the "buffer" each time the operation is invoked ... regardless of if
the "available" buffer if full.
So this brings about many questions.
First, when I send 1000 packets that are 144 bytes long through the
UDP socket, is 144,000 bytes sent? Or are 144 * 1500 (MTU Size) bytes
sent?
If only 144,000 bytes are sent, why does the BeginReceiveFrom
operation only populate one packet into the buffer per call to the
BeginReceiveFrom operation?