TCP and ENCODING

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Siddharth Sood via .NET 247

    #1

    TCP and ENCODING

    Hi,

    I am having a real issue with sending data across a network.

    I have a string that is composed of the following:

    NEW|192.168.0.1 2|_000000038|_0 00000001|_00000 0109|312886|1|0 |_000000001|C|A UTO-ASSIGN|??| ||EN|

    I am using the method below to send this string to another systemover tcp that accepts the data over port 5021.

    All data is transferred to the other system except the "??". Thisis in hindi or it can be in any other language. The problemarises when the other system receives the data; the "??" isdisplayed as ???. How do i send a string in a diffrent languageover TCP. Your help is appreciated.

    public string GetToken(string tosend)
    {
    try
    {
    m_socWorker = new Socket(AddressF amily.InterNetw ork,SocketType. Stream, ProtocolType.Tc p);
    string szIPSelected = GetIPaddress();
    string szPort =System.Configu ration.Configur ationSettings.A ppSettings["RemotePort "];
    int alPort = System.Convert. ToInt16(szPort, 10);
    System.Net.IPAd dress remoteIPAddress =System.Net.IPA ddress.Parse(sz IPSelected);
    System.Net.IPEn dPoint remoteEndPoint = newSystem.Net.I PEndPoint(remot eIPAddress, alPort);
    m_socWorker.Con nect(remoteEndP oint);

    Object objData = tosend;
    byte[] byData =System.Text.En coding.ASCII.Ge tBytes(objData. ToString ());
    m_socWorker.Sen d(byData);
    }
    }


    Thanks
    --------------------------------
    From: Siddharth Sood

    -----------------------
    Posted by a user from .NET 247 (http://www.dotnet247.com/)

    <Id>J/KMV/PTMUehQhyQJGCxz A==</Id>
  • stand__sure

    #2
    Re: TCP and ENCODING


    Siddharth Sood via .NET 247 wrote:[color=blue]
    > byte[] byData = System.Text.Enc oding.ASCII.Get Bytes(objData.T oString[/color]
    ());[color=blue]
    > m_socWorker.Sen d(byData);[/color]

    ASCII? try

    System.Text.Enc oding.Unicode.G etBtyes

    Comment

    Working...