PDA

Click to See Complete Forum and Search --> : Connecting socket from behind proxy server


steve_rm
May 4th, 2009, 01:06 AM
Hello,

VS 2008

I am using the code below to detect if the client can connect to our sip server. This was working fine. However, the client has changed there network and now my application has to connect to the sip server from behind a proxy server.

The error I get is "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond xxx.xxx.xx.xx:xx"

This code was working ok, until I have to connect from behind a poxy server.

I could not see any properties there I can add the proxy address to the socket.

Am I missing something?

Many thanks for any suggestions,

public bool IsSIPServerAvailable()
{
bool isAvailable = true;
Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);

try
{
sock.Connect("xxx.xxx.xx.xx", xx);
}
catch (SocketException ex)
{
Console.WriteLine(ex.Message);
isAvailable = false;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
isAvailable = false;
}
finally
{
if (sock.Connected)
{
sock.Close();
}
}

return isAvailable;
}

Atheist
May 7th, 2009, 02:32 PM
I don't believe you'd need to worry about the computer being behind a proxy. I havent worked much with proxies but thats my understanding. Can the PC running this application behind the proxy access the internet in any other way (web etc)?