Перейти к содержимому

Что такое сетевой сокет?

-4

Я слышал много разных определений онлайн, и мне было трудно понять, что такое сокет.
Было бы замечательно, если бы кто-то смог зажечь свет там, где мне темно.

341 просмотр
Joseph A. спросил 10 лет назад
J 937

3 ответа

1
Принятый ответ

An analogy that I've heard before is that a network socket is similar to a regular electrical wall socket in the way that both are used to make a connection to another location. More precisely, a network socket is something that is opened or closed just like a file, but instead of reading or writing data to a disk, you are sending and/or receiving network packets. The socket is opened with a command (depending on what language or platform you are using) which will cause (in the case of a TCP connection) a 3-way handshake that initiates the connection. Sending data to the socket will cause that data to be sent through to the other system.

Just like a file, it should be closed when you are finished with it, and there's another command that will do that as well, again depending on your OS and platform.

Hopefully that makes sense.

Tim S. ответил 10 лет назад
T 147
0

Network Socket Address is a combination of IP address and port number separated by colon.

Eg: 192.168.1.1:23

This means 192.168.1.1 is listening on port 23 and can accept telnet data which is coming to 192.168.1.1

Likewise you can say 192.168.1.1:80 is a network socket and is ready to process HTTP data.

manjesh23 ответил 10 лет назад
M 1 319
-4

This can be googled easy. But since I have time:

A socket is one endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent to. An endpoint is a combination of an IP address and a port number.

via Oracle Tutorial

Сокет не является связью конечной точки. Сокет представляет собой комбинацию IP-адреса и номера порта, разделенных двоеточием.

manjesh23 · 10 лет назад · 0
CarlosFMeneses ответил 10 лет назад
C 1