Reputation: 39
I am learning socket programming now and made a simple tcp/ip chatting application using c++. I can only talk to myself since it only works for localhost. Now I want to let people to connect to my device. I read many articles and come up with some questions and thoughts:
If I am using Ethernet (with firewall), the external ip would be masked by firewall and hence it would be different than the internal ip.
If I am using Wifi (my own router), the external ip would be different than the internal ip, and the internal ip would be like 192.168.x.xxx.
If I am using public wifi, such as apartment wifi and campus wifi, how can I open a port on the firewall? Talk to the IT staff?
I am not ready to rent a server atm. I want to make sure my chatting application can work on different devices. That's why I want to let my friends connect to my device and test it.
Please correct me if my concepts are wrong. Also, I will appreciate if you can recommend me any good sources for learning tcp/ip or networking.
Upvotes: 0
Views: 63
Reputation: 182769
If I am using Ethernet (without firewall), would my external ip and internal ip be the same?
If you aren't using any kind of router and just connect one machine directly to your incoming internet connection, maybe. Otherwise, the router will have to assign each machine an internal address that is distinct from the router's external address. Otherwise, how would it tell them apart?
If I am using Ethernet (with firewall), the external ip would be masked by firewall and hence it would be different than the internal ip.
It's not so much a firewall that does this but a NAT device. These are used when you have fewer valid external IP address (those are precious) than devices that need internet access. That makes the use of distinct internal and external addresses necessary.
If I am using Wifi (my own router), the external ip would be different than the internal ip, and the internal ip would be like 192.168.x.xxx.
That's a common way to do it. It's the same if you're using Ethernet. The issue is more internal devices than available external addresses.
If I am using public wifi, such as apartment wifi and campus wifi, how can I open a port on the firewall? Talk to the IT staff?
If they don't support UPnP (which does it automatically) you probably can't. But you could, in theory, try talking to their IT staff.
Upvotes: 2