I have the following code to receive the response from a Server.
byte[] responseBuffer=new byte[1];
Socket destServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
destServerSocket.Connect(remoteHost, portno);
//State 2: Sending New Request Information to Destination Server and Relay Response to Client
destServerSocket.Send(ASCIIEncoding.ASCII.GetBytes(requestPayload));
Console.WriteLine("Sent the Request to Server...");
Console.WriteLine("Begin Receiving Response...");
String Response = "";
while (destServerSocket.Receive(responseBuffer) != 0)
{
Console.Write(ASCIIEncoding.ASCII.GetString(responseBuffer));
Response += ASCIIEncoding.ASCII.GetString(responseBuffer);
if (this.clientSocket.Connected)
this.clientSocket.Send(responseBuffer);
else
{
Console.WriteLine("Socket Disconnected");
break;
}
}
Console.WriteLine("Received the Response as {0}", Response);
destServerSocket.Disconnect(false);
destServerSocket.Dispose();
this.clientSocket.Disconnect(false);
this.clientSocket.Dispose();
I tried to debug and The Visual Studio just stops and doesn't exit Debugging mode but no clue of where the execution went. Could anyone help me with this weird behavior of C#. I have attached herewith the Output Screen image for your reference.
Thanks,