Search code examples
c#socketstcpnetwork-programmingiptv

Receive acknowledgement from TCP Socket


I am Sending some Command to lg iptv. some command like:

Current temperature (Command: d n)
Checks the inside temperature.
Transmission
[d][n][ ][Set ID][ ][Data][Cr]
Data FF: Check the status
Acknowledgement
[n][ ][Set ID][ ][OK/NG][Data][x]
* Temperature is displayed as a hexadecimal value.

i am creating a tcp socket with this line of code:

Socket client = new Socket(AddressFamily.InterNetwork,
                    SocketType.Stream, ProtocolType.Tcp);

and i connect and send some commands. they are working fine but i cannot receive Ack with these lines of code:

data = data + "\r";
byte[] bytes = new byte[1024];
byte[] msg = Encoding.ASCII.GetBytes(data);
int bytesSent = user.Send(msg);
user.ReceiveTimeout = 2000;
int bytesReceived = user.Receive(bytes);
data = Encoding.ASCII.GetString(msg, 0, bytesReceived);

i used this example of msdn and again nothing received. https://msdn.microsoft.com/en-us/library/bew39x2a(v=vs.110).aspx

is there any way to receive that ack? i just can write client side and server side is in that tv.


Solution

  • It is not possible to receive ack. because it is not exposed to the application level. The TCP protocol will keep resending the packet until it receives a successful ACK.