Socket problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • whetham63

    Socket problem

    When I run this on my network at home and on my network at work it runs fine.
    When this is run at a clients network I am receiving a [FIN, ACK] after the
    first packet is received(There are 2 packets returned). I am not usre if t is
    a problem with the code or with the clients network.

    I am using the following Code:
    public string DoSocketGet(str ing inputRequest)
    {
    // Create TcpClient
    TcpClient client = new TcpClient(serve rIP, serverPort);
    // Translate the passed message into ASCII and store it as a Byte array.
    Byte[] data = System.Text.Enc oding.ASCII.Get Bytes(inputRequ est);
    // Get a client stream for reading and writing.
    // Stream stream = client.GetStrea m();
    NetworkStream stream = client.GetStrea m();
    // Send the message to the connected TcpServer.
    stream.Write(da ta, 0, data.Length);
    // Receive the TcpServer.respo nse.
    System.IO.Strea mReader reader = new System.IO.Strea mReader(stream) ;
    System.Text.Str ingBuilder response= new StringBuilder() ;
    while(reader.Pe ek() > 0)
    {
    response.Append ((char)reader.R ead());
    }
    reader.Close();
    stream.Close();
    client.Close();
    return response.ToStri ng();
    }

Working...