Mann Maurya

Mann Maurya

  • NA
  • 104
  • 9.5k

Sending Data using LAN port

Jun 11 2019 6:20 AM
I am trying to send data through lan port using port:1080;
 
The following code is working fine till MessageId1:127,
 
when MessageId1:128 or more than that code not working
 
MessageId0=000;
MessageId1=128;
public void SenData()
{
hexString = "007" + MessageId0 + MessageId1 + "000003000000000" + MessageId0 + MessageId1 + "002";
HexString2Ascii(hexString);
msgSend = System.Text.Encoding.ASCII.GetBytes(Label1.Text);
stream.Write(msgSend, 0, msgSend.Length);
}
private string HexString2Ascii(string hexString)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i <= hexString.Length - 3; i += 3)
{
sb.Append(Convert.ToString(Convert.ToChar(Int32.Parse(hexString.Substring(i, 3), System.Globalization.NumberStyles.Number))));
}
Send = sb.ToString();
return sb.ToString();
}
 
pls Suggest any changes in code.
 
pls Help guys!
thanks !

Answers (1)