H
Hiroyuki Tanaka
Dear Readers,
I am trying to learn C# network programming and I have discovered that
Windows TCPIP often joins small packets and send them as one to the
remote server. This appears to be a default behaviour of TCPIP?
I am attempting to send 1000 TCPIP packets to a remote sever with only
a sequence number (and soon a variable length message (only a few
characters)) in them.
packet 0 0
packet 1 1
packet 2 2
....
packet 100 100
....
packet 999 999
So at my remote server I wish to receive 1000 packets each with a
single number in each packet.
However at my server I get packets that include all the number to 100
(for example) joined together.
How can I force the C# socket send to send just the buffer I want in
each packet?
Thanks
Tanaka
private void send_Click(object sender, System.EventArgs e)
{
int port = 5000;
Socket tcpsocket;
tcpsocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
IPEndPoint remoteServerEndPoint = new IPEndPoint(IPAddress.Parse(
"10.1.1.1" ), port );
tcpsocket.Connect(remoteServerEndPoint);
for (int i= 0; i < 1000 ; i++)
{
string count = i.ToString();
Byte[] socketbuffer = new byte[count.Length];
for (int j = 0; j < count.Length; j++)
socketbuffer[j] = System.Convert.ToByte(count[j]);
tcpsocket.Send(socketbuffer, 0, socketbuffer.Length,
SocketFlags.None);
}
tcpsocket.Close();
}
I am trying to learn C# network programming and I have discovered that
Windows TCPIP often joins small packets and send them as one to the
remote server. This appears to be a default behaviour of TCPIP?
I am attempting to send 1000 TCPIP packets to a remote sever with only
a sequence number (and soon a variable length message (only a few
characters)) in them.
packet 0 0
packet 1 1
packet 2 2
....
packet 100 100
....
packet 999 999
So at my remote server I wish to receive 1000 packets each with a
single number in each packet.
However at my server I get packets that include all the number to 100
(for example) joined together.
How can I force the C# socket send to send just the buffer I want in
each packet?
Thanks
Tanaka
private void send_Click(object sender, System.EventArgs e)
{
int port = 5000;
Socket tcpsocket;
tcpsocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
IPEndPoint remoteServerEndPoint = new IPEndPoint(IPAddress.Parse(
"10.1.1.1" ), port );
tcpsocket.Connect(remoteServerEndPoint);
for (int i= 0; i < 1000 ; i++)
{
string count = i.ToString();
Byte[] socketbuffer = new byte[count.Length];
for (int j = 0; j < count.Length; j++)
socketbuffer[j] = System.Convert.ToByte(count[j]);
tcpsocket.Send(socketbuffer, 0, socketbuffer.Length,
SocketFlags.None);
}
tcpsocket.Close();
}