Home > Backend Development > PHP Tutorial > Summary of the series of socket functions in php, phpsocket series of functions_PHP tutorial

Summary of the series of socket functions in php, phpsocket series of functions_PHP tutorial

WBOY
Release: 2016-07-13 09:53:39
Original
826 people have browsed it

A summary of the series of socket functions in php, phpsocket series of functions

This article lists all the functions that use socket-related services in the PHP language. Note that before using the following functions, you need to ensure that your socket is open. If you have not opened it, please edit your php.ini file and remove the comment (semicolon) in front of the following line:
Copy code The code is as follows:
extension=php_sockets.dll

If you cannot remove the comment, please use the following code to load the extension library:
Copy code The code is as follows:
if(!extension_loaded('sockets')){
if(strtoupper(substr(PHP_OS,3))=="WIN"){
dl('php_sockets.dll');
}else{
dl('sockets.so');
}
}

If you don't know whether your socket is open, then you can use the phpinfo() function to determine whether the socket is open. You can check whether the socket is open by checking the phpinfo information.

php socket related functions are as follows:
Copy code The code is as follows:
socket_accept() Accept a Socket connection
socket_bind() Bind the socket to an IP address and port
socket_clear_error() Clear socket error or last error code
socket_close() Close a socket resource
socket_connect() Start a socket connection
socket_create_listen() Open a socket listening on the specified port
socket_create_pair() Generates a pair of indistinguishable sockets into an array
socket_create() Generates a socket, which is equivalent to generating a socket data structure
socket_get_option() Get socket options
socket_getpeername() Get the IP address of a remote similar host
socket_getsockname() Get the IP address of the local socket
socket_iovec_add() Adds a new vector to a scatter/aggregate array
socket_iovec_alloc() This function creates an iovec data structure that can be sent, received, read and written
socket_iovec_delete() Delete an allocated iovec
socket_iovec_fetch() Returns the data of the specified iovec resource
socket_iovec_free() Release an iovec resource
socket_iovec_set() Set the new value of iovec data
socket_last_error() Get the last error code of the current socket
socket_listen() Listens to all connections from the specified socket
socket_read() Read data of specified length
socket_readv() Read data from scatter/aggregate array
socket_recv() Finish data from socket to cache
socket_recvfrom() accepts data from the specified socket. If not specified, it defaults to the current socket
socket_recvmsg() Receive messages from iovec
socket_select() Multiple selection
socket_send() This function sends data to the connected socket
socket_sendmsg() Send message to socket
socket_sendto() Send a message to the socket at the specified address
socket_set_block() Set to block mode in socket
socket_set_nonblock() Set the socket to non-block mode
socket_set_option() Set socket options
socket_shutdown() This function allows you to close reading, writing, or the specified socket
socket_strerror() Returns the detailed error of the specified error number
socket_write() Write data to socket cache
socket_writev() Write data to scatter/aggregate array

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1000252.htmlTechArticleA summary of the series of socket functions in php. The phpsocket series of functions. This article lists all the socket-related services in the PHP language. some functions. Note that before using the following functions, you need to...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template