Reputation: 3100
I am attempting to interop with a custom hardware device.
It requires the first TCP packet to contain a data payload
I tried to achieve this using TcpClient in System.Net.Sockets
TcpClient tcpclnt = new TcpClient();
tcpclnt.Connect("192.168.1.11", 1500);
Stream stm = tcpclnt.GetStream();
byte[] ba = messagestr.StringToByteArray();
stm.Write(ba, 0, ba.Length);
However wireshark shows that this code sends a number of TCP/IP packets to establish a connection and the data packet (containing messagestr) is the 4-5th packet.
How can I make C# send the data in the FIRST TCP packet?
Upvotes: 1
Views: 2034
Reputation: 294237
Use UDP to send only one packed without establishing a session. You are literally asking TCP not to be TCP.
Upvotes: 3