开发者

How to make socket connection over internet?

I'm making two programs; a "server" application (single instance), and a client application (multiple instances), that connects to the server app. There will be continuous (but light) data sent between the server app and the client apps, but no communication between the client applications.

So far I'm successfully testing this with open socket connections between computers on my local network. So that means I'm using the IP-addresses found in cmd > ipconfig. The server app uses TcpListener / TcpClient. I don't really know if that's the best connection to use, or if there are others (?), but that's all I have learned.

What is now required to m开发者_运维知识库ake this work over internet? I assume I will send connection request to the external IP address, but do I need to make any more sophisticated changes to the requests?

And do I need to make some settings in the router? If so, what type?

Any hints would be appreciated, as you see, I'm not much familiar with this.


You can continue to use sockets. To make communication to the server easier, use a host name instead of an IP address; that way, the server is free to change IP addresses without the clients needing to be re-deployed.

Another issue to consider is firewalls. You'll need to make sure that the host for the server application allows inbound connections to the TCP port it's listening on, and also that any router that it's behind also allows inbound traffic to that port. Also, clients may have connectivity issues if they have firewalls blocking outbound traffic.


You could use a WCF service instead of sockets. They have duplex modes and TCP/IP.

You then need a computer with static IP so you can expose your service over the net.

Check out this article: http://keithelder.net/2008/01/17/exposing-a-wcf-service-with-multiple-bindings-and-endpoints/


You should be hosting your tcp server in a demilitarized zone http://en.wikipedia.org/wiki/DMZ_(computing) or setup your router to do NAT (port forwarding) from the outside to the server http://en.wikipedia.org/wiki/Port_forwarding

The firewall on the router should allow connection to the required port.

You should read you router manual if you are not sure what you are doing in the settings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜