Networking question

I

Ioannis Vranos

When we have a TcpClient or TcpServer or UdpClient, receiving data and then processing
them inside an infinite loop, inside a method executed by a Thread, I assume that the data
being received while the previous data are processed inside the loop, are queued or
something and are not dropped right? Exactly how much data this "queue" can hold?


An example of such a member function:

// UdpClient *client;
// IpEndPoint *receivePoint;
void Form1::WaitForPackets()
{
while(true)
{
Byte data __gc[]= client->Receive(&receivePoint);

displayTextBox->Text= String::Concat(displayTextBox->Text, S"\r\nPacket received: ",
S"\r\nLength: ", data->Length.ToString(), S"\r\nContaining: ",
System::Text::Encoding::ASCII->GetString(data), S"\r\n");
}
}
 
W

Willy Denoyette [MVP]

Ioannis Vranos said:
When we have a TcpClient or TcpServer or UdpClient, receiving data and
then processing them inside an infinite loop, inside a method executed by
a Thread, I assume that the data being received while the previous data
are processed inside the loop, are queued or something and are not dropped
right? Exactly how much data this "queue" can hold?


An example of such a member function:

// UdpClient *client;
// IpEndPoint *receivePoint;
void Form1::WaitForPackets()
{
while(true)
{
Byte data __gc[]= client->Receive(&receivePoint);

displayTextBox->Text= String::Concat(displayTextBox->Text,
S"\r\nPacket received: ",
S"\r\nLength: ", data->Length.ToString(),
S"\r\nContaining: ",

System::Text::Encoding::ASCII->GetString(data), S"\r\n");
}
}

The network stack queues the data received at several levels, the size of
the queues are dynamically adjusted depending on a numer of parameters like
OS version, network configuration settings, speed etc..
The data in the queues are simply waiting to be passed to the application in
case of a receive or to the network in case of a send, the remaining queued
data is dropped when a socket is closed however.

Willy.
 
I

Ioannis Vranos

Willy said:
The network stack queues the data received at several levels, the size of
the queues are dynamically adjusted depending on a numer of parameters like
OS version, network configuration settings, speed etc..
The data in the queues are simply waiting to be passed to the application in
case of a receive or to the network in case of a send, the remaining queued
data is dropped when a socket is closed however.


An interesting property that I came across is Socket::Available. It returns the amount of
bytes that are queued and wait to be received by the application. Now one can easily
create a sample application that will keep sending to itself without receiving, and will
be displaying the current value of Socket::Available until something happens (if it
happens). :) If there is an upper "hard-coded" (that is in windows or .net source code)
limit of the receive queue, it will be shown in this way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top