Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

sending xml request via TCPClient takes long to receive response.

$
0
0

Good day guys,

i have a problem where im trying to connect to a host using the ip address provided, but i cant seem to be able to get a response from it.

    try
                {
                    Socket serverSock = new Socket(
                 AddressFamily.InterNetwork,
                 SocketType.Stream,
                 ProtocolType.Tcp);


    IPAddress serverIP = IPAddress.Parse("");
                  IPEndPoint serverEP = new IPEndPoint(serverIP, port);
         Byte[] data = System.Text.Encoding.ASCII.GetBytes(postData);



                    NetworkStream stream = client.GetStream();

                    stream.Write(data, 0, data.Length);

                    Console.WriteLine("Sent: {0}", postData);

                    data = new Byte[256];

                    String responseData = String.Empty;


   SocketPermission perm = new SocketPermission(NetworkAccess.Accept, TransportType.Tcp, "", port);
                    Int32 bytes = stream.Read(data, 0, data.Length);
                    responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
                    Console.WriteLine("Received: {0}", responseData);


                    stream.Close();
                    client.Close(); 

   }
                catch (Exception)
                {

                    throw;
                }     


after that i will capture the response and load it into xml document. But im not receiving any response at all. it as it its hanging...

kind regards

Tony


Viewing all articles
Browse latest Browse all 555

Trending Articles