Dark Star1
Dark Star1

Reputation: 7413

Why is C# triggering a Socket Timeout issue on another machine?

I ran an application on my machine and it ran fine; I then run the apoplication on another machine but I'm getting a socket timeout isse connecting to the box even though Pinging works fine. Below is my socket connection Logic:

        private bool openConnection(out IPEndPoint connection_Point)
    {
        bool connected = false;
        connection_Point = new IPEndPoint(m_address, m_port);
        m_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        m_sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
        try
        {
            m_sock.Connect(connection_Point);
            connected = true;
        }//end of try logic
        catch (SocketException err)
        {
            connected = false;
            connection_Point = null;
            MessageBox.Show("Socket Exception thrown: " + err);
        }

        return connected;
    }

Upvotes: 0

Views: 251

Answers (2)

Remus Rusanu
Remus Rusanu

Reputation: 294437

ping will only tell if the IP address responds to pings. To confirm that a TCP socket can be opened, try telnet on the listening port from the new machine. If telnet doesn't connect, the likely culprits are firewall and/or IPSec.

Upvotes: 2

STW
STW

Reputation: 46394

Firewall? Sounds like firewall to me...

Upvotes: 1

Related Questions