-
first of all, you have to understand the meaning of context socket here: socket refers to http socket, which is built on tcp/ip/mac/ optical fiber cable (transport layer / network layer / link layer / entity layer). Socket, commonly known as socket, is end-to-end communication (client / server), not unilateral behavior. Tcp determines the port, ip+mac determines the host, host + port is the http socket here.
who says PHP is just something on the server side? Pull it out and play PP! The questions asked by the injured LZ are all wrong.
can connect to socket services on other machines, when the client connects
socket is a communication mechanism. One side of the link is the client and the other is the server
.
such as
stream_socket_server
is to create a server socket
corresponding to it, there must be a client connecting to the server
stream_socket_client
so in fact, it is not the initialization of PHP server or client socket, which is simply distinguished in PHP usage
by the way, PHPsocket has two types of functions that can be implemented, such as stream_socket_ series and socket_ series
.
suggest the landlord to read another article (https://codeshelper.com/a/11.).
the concept of the original text is not clear, and some things are too vague.
for example:
Socket is used for interprocess communication. -- Socket can be used for inter-process communication (which requires networking), but Socket is mainly inter-network communication.
Socket is essentially an encapsulated api, not a protocol, but an api between the application layer and the transport layer.