Click here to Skip to main content
15,893,790 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am Working On Typical tcp Client Server Application Where Server Continuously Sends The Messages To Client And Client In turn Sends Ack/Nak as Response To Server . Now I want To Decode The Message Received From The Server In Client Application . How Can I do that Using .net FrameWork?
Posted
Updated 8-Sep-14 21:05pm
v2
Comments
Herman<T>.Instance 9-Sep-14 4:31am    
use a TcpListener for that

The message received at client end will be in term of bytes array.

You will need to decrypt this byte array in normal string.

see below.

string resultingString = Encoding.ASCII.GetString(receivedEncodedBytes, 0 , receivedEncodedBytes.Count);

here receivedEncodedBytes is a byte array received in tcp Client.

Note: If there is anyother encoding format(other than Encoding.ASCII) is being used at server end you will also need to use the same format at client side.
 
Share this answer
 
v4
Refer - A Network Sniffer in C#[^]. It might be helpful.
 
Share this answer
 
CSocketPacket theSockId = (CSocketPacket)asyn.AsyncState;
//end receive...
int iRx = 0;
iRx = theSockId.thisSocket.EndReceive(asyn);
char[] chars = new char[iRx + 1];
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
System.String szData = new System.String(chars);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900