Hi, I made a game and i would like to have a client server, ive been able to use TcpListener with internal ip such 127.0.0.1 or 192.168.1.100. But when it comes to make it work through internet (external ip) it does not work. Anybody would know why?

Thanks for your help

Most likely you have a router that is blocking your port. also its a good chance you don't have a static IP and your IP address is changing.

The server must be directly exposed to the net by forwarding the port it uses from your router to the local IP address of the computer running the server.

Most likely you have a router that is blocking your port. also its a good chance you don't have a static IP and your IP address is changing.

The server must be directly exposed to the net by forwarding the port it uses from your router to the local IP address of the computer running the server.

Ok but,

I have forwarded the port 4296 on my router.
In the server app I do TcpListener("Ipextern", 4296); and it gives a error.
Why?
I do not have the chance to do tcpClient.Connect(sIpAdresse, 4296); on the client, I run both on the same machine for now (localy).

Thanks

TcpListener("Ipextern", 4296);

Why is IPextern in quotations. The TCPListner class takes an IPAddress object here, not a string. Or you could simply just just use the port number and no IPaddress and it should work fine.

the TCP Listener and TCP client classes make network programming dirt simple. Its easy to get confused. I had trouble starting it a while back. Sknake posted a project on my thread that was a working Client server pair if you are interested here is the link

http://www.daniweb.com/forums/thread228973.html

Why is IPextern in quotations. The TCPListner class takes an IPAddress object here, not a string. Or you could simply just just use the port number and no IPaddress and it should work fine.

the TCP Listener and TCP client classes make network programming dirt simple. Its easy to get confused. I had trouble starting it a while back. Sknake posted a project on my thread that was a working Client server pair if you are interested here is the link

http://www.daniweb.com/forums/thread228973.html

Sorry:

IPHostEntry ipEntry = Dns.GetHostEntry(Dns.GetHostName());
IPAddress[] addr = ipEntry.AddressList;
chatServer = new TcpListener(addr[0], 4296);

I use this cause:
TcpListener(int)' is obsolete: 'This method has been deprecated. Please use TcpListener(IPAddress localaddr, int port) instead

I'll check the post

Thanks

Edited 6 Years Ago by Bernybon: n/a

IPAddress ipAd = IPAddress.Parse("214.236.233.5"); // ip extern
chatServer = new TcpListener(ipAd, 4296);

Why this fail ?

If I use the 192.168.1.100 and try to connect from the client, it fail.. it is because i'm on the same machine ?

Thanks

Edited 6 Years Ago by Bernybon: n/a

check using your local IP address and see if it works, If it does then you know its a router setting problem. Other than that it should work, making a listener and an client are just a few lines of code you are showing it right so the problem must be else where.

This article has been dead for over six months. Start a new discussion instead.