Reputation: 31
I have tried to find out over the internet but i didnt find the answer . I am working on an application in C# using Tcpclient
TcpClient tcpClientB = new TcpClient ("IP", 6666);
this works well if we deploy the server part on some web server having static IP or in a network where client and server are in same network , but what about all those machines which are connected to internet but dont have static IP over the web . e.g machines connected to a network in an office but have internet connection . What is the work around without using a web server to help communicate between them.
Upvotes: 0
Views: 157
Reputation: 93444
There is no workaround. You either need the machine on the other end to be open to the internet on that port or you need an intermediate server to connect two machines. It has nothing to do with a static IP really, since you can just as easily connect to a dynamic ip if you know it.
The reason should be obvious.
The fact is, one side of the connection has to be publicly open to the internet, which usually means having an intermediary server to connect them if you want any kind of reliability.
There are networks, such as bittorrent's DHT network that, once you connect to an intermediate server and connect to one or more peers, you can use those peers connected clients to connect to other clients. But, this must start with some public intermediary server.
NOTE: The term "broadcast" means issuing a special packet to all addresses on the subnet. You can't "broadcast" to the internet. You can only broadcast to your own subnet.
Every subnet has two "unusable" Ip addresses, one at the beginning and one at the end. These are the default and broadcast addresses. if you have a class C subnet (255 addresses), then these are .0 and .255 respectively. For example, 10.0.0.0 and 10.0.0.255 or 192.168.0.0 and 192.168.0.255
Upvotes: 1