Results 1 to 2 of 2

Thread: Connecting socket from behind proxy server

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Connecting socket from behind proxy server

    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,

    Code:
    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;
        }
    steve

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Connecting socket from behind proxy server

    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)?
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width