My program implementing http client (by inheriting from TCPClient) which sends requests to http server in order to get chunk transfer encoding streaming (in other words, video stream over HTTP).
In order to monitor connection between client and server I started background thread that trying to write null byte (0x00) to the same socket and discover connection problems accordingly (as recommended here):
while (Client != null && Client.Send(ping) > 0)
Thread.Sleep(2000);
The impact of writing from two threads is that in Wire-shark sometimes I see that ping and the HTTP request in the same packet, like this:
00 10 18 8d 23 ab 00 11 5d b9 e8 00 08 00 45 00 ....#...].....E.
00 b1 38 21 40 00 3e 06 77 de 0a 3f 03 3d 0a 3f ..8!@.>.w..?.=.?
74 8d 89 7f 00 50 6b c3 45 a8 9f 76 4a 88 80 18 t....Pk.E..vJ...
13 5d a9 ad 00 00 01 01 08 0a 9c ea b6 a5 00 06 .]..............
9f 8b 47 45 54 20 2f 73 74 72 65 61 6d 2f 31 2f ..GET /stream/1/
45 76 65 6e 74 41 20 48 54 54 50 2f 31 2e 31 0d EventA HTTP/1.1.
And of course the server ignore this packet and can't see the http request.
Is there any way to write to socket and using Send method and make sure it will be sent in ONE packet?
[EDIT]
As I can understand from David and TAS's answers - that is not possible. And this is not even how TCP meant to operate.