Studied computer networks. I hit a dead end ... Some suffer with closed ports, when using any programs (uTorrent, skype)

I will give an example of pseudo-code that deploys a simple tcp-server:

s = socket() s.bind('localhost', 3333) s.listen(3) 

As I understand it, this code expands the server only on the local host (?!) How, then, does the program establish a connection with the server? How does she send the data?

A server located hundreds of kilometers away will not be able to send data to 123.123.123.123:3333 ?? If the ip client (program) is not dedicated and the provider does not allow opening ports ??!

I've checked, skype no open ports on my external ip .. It turns out that the ports are internal and external ??

  • A port is just a number (which is transmitted along with your data), through which the OS determines which application to send it to. - Vladimir Gamalyan
  • > As I understand it, this code expands the server only on the local host (?!) How, then, does the program establish a connection with the server? How does she send the data? In the sense of? It connects to the server via ip and port and sends data as usual. - Dagger

1 answer 1

Some suffer with closed ports when using any programs (uTorrent, skype)

The term "closed port" in this case is erroneous.

Either the port is disabled (the anti-virus / firewall settings do not allow forming a socket listening on this port, that is, receiving packets arriving on this port), or busy (the socket listening on this port is already formed by another process, and this resource is not shared). However, the ban is organized precisely as employment, although in reality the port is not busy.

Internal and external ports do not exist. There is a local port (on this host) and a remote port (on the host you are sharing the network with).

UPD: "Closed port" is when the application was able to form a listening socket, but all packets arriving at this port are intercepted (and dropped) by the firewall / antivirus.

  • for example, I gave a friend a written echo server (udp), he launched ... I send him a request, to his external ip and port 3333 ( 123.123.123.123:3333 ) ... while his ip is not dedicated, he normal user on Windows. will my request come up? - monsiure
  • его ip не является выделенным - decipher. он обычный юзер на винде - and this is what? hint that he is a lamer? я отправляю ему запрос, на его внешний ip - that is, he has a "gray" address and connection via NAT or proxy? and while not purchased the service "white" address? Of course, it will not come. - Akina
  • его ip не является выделенным - его ip не является белым . Thank. And how then does the p2p network work, if you take skype , for example? - monsiure
  • The p2p network uses an external server (third node) with a white address. At least to initiate the connection, but more often during the entire exchange session. Those. each of their end nodes communicates with the server, and the latter relays the stream to the second end node. And back. - Akina