views:

1271

answers:

6

I can run the server on my local machine and connect to it on the same machine, but when i try to connect to it from a different computer over the internet, there is not sign of activity on my server, nor a response from the server on the computer im testing on. Ive tried both XP and vista/turn off firewalls/opened ports/run as admin; nothing is working :(

Here is my code that im used to accept an incoming connection:


int port = 3326;
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            try
            {
                TcpListener listener = new TcpListener(new IPEndPoint(IPAddress.Any, port));
                listener.Start();
                Console.WriteLine("Server established\nListening on Port: {0}\n", port);
                while (true)
                {
                    socket = listener.AcceptSocket();
                    socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, outime);
                    socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
                    socket.DontFragment = true;
                    NewConnection pxy = new NewConnection(socket);
                    Thread client = new Thread(new ThreadStart(pxy.Start));
                    client.IsBackground = true;
                    client.Start();
                }
}
Please help!

C#.NET3.5

A: 

If you are trying this at home, your ISP may be in yer webz messing with teh t00bz.

Justin Bozonier
A: 

what? Yes i'm trying this at home, but also on other ISP networks. So i dont think it is ISP specific

Dacto
+6  A: 

I think that the problem is in your router, not in your computer. When traffic comes from the Internet it should be routed to an specific server. You have to configure your router to redirect the traffic on port 3326 to your server.

hectorsq
A: 

I already disconnected my router and directly connected my pc to the modem, but you guys dont see anything wrong with my code?

Dacto
Even with the computer connected directly to your modem, the modem itself could be blocking the incoming traffic in that port.
hectorsq
ok, i'll check that
Dacto
+2  A: 

You've probably got something blocking the connection higher up. Try connecting from another host on the LAN. If you can do that, then the OS itself isn't firewalling the connection.

If either you or your ISP run a NAT router, then your machine probably doesn't have a publicly accessible address, in which case it's impossible to connect directly to it.

If there is no NAT router, something may still be blocking the connection upstream.

MarkR
i can connect via a different host on the LAN, am i able to use my router to port forward to the server machine. I remember a while ago i hosted a VOIP server - Teamspeak and ventrilo on my LAN which was accessible via internet, can i do something similar with this?
Dacto
A: 

I was being serious lol. Most ISPs actively work to disable you using your home connection as a web server. Might wanna call them before you invest too much time.

Justin Bozonier