Socket Receive problem
- From: whetham63 <whetham63@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 11 May 2005 13:32:02 -0700
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(string inputRequest)
{
// Create TcpClient
TcpClient client = new TcpClient(serverIP, serverPort);
// Translate the passed message into ASCII and store it as a Byte array.
Byte[] data = System.Text.Encoding.ASCII.GetBytes(inputRequest);
// Get a client stream for reading and writing.
// Stream stream = client.GetStream();
NetworkStream stream = client.GetStream();
// Send the message to the connected TcpServer.
stream.Write(data, 0, data.Length);
// Receive the TcpServer.response.
System.IO.StreamReader reader = new System.IO.StreamReader(stream);
System.Text.StringBuilder response= new StringBuilder();
while(reader.Peek() > 0)
{
response.Append((char)reader.Read());
}
reader.Close();
stream.Close();
client.Close();
return response.ToString();
}
.
- Prev by Date: Re: .Net (C#) Service Fails To Start
- Next by Date: Re: Threading/Locking
- Previous by thread: possible Nube question about system messages - please help
- Next by thread: How to get class name?
- Index(es):
Relevant Pages
|