Home > Backend Development > PHP Tutorial > php socket related functions_PHP tutorial

php socket related functions_PHP tutorial

WBOY
Release: 2016-07-13 09:53:32
Original
725 people have browsed it

php socket related functions

This article lists all the functions related to using socket related services in 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:

extension=php_sockets.dll

If you cannot remove the comment, please use the following code to load the extension library:

<?php
if(!extension_loaded('sockets')){
	if(strtoupper(substr(PHP_OS,3))=="WIN"){
		dl('php_sockets.dll');
	}else{
		dl('sockets.so');
	}
}
Copy after login

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:

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

Articles you may be interested in

  • JavaScript related functions for operating cookies
  • php calculates two Function to calculate the number of days (days) between dates
  • PHP function to calculate the number of years, months and days between two dates
  • PHP uses the session_set_save_handler() function to save the session to the MySQL database
  • Summary of PHP file, folder (directory) operation functions
  • php window platform simulates the checkdnsrr function to detect whether the email actually exists
  • Solution to the 8-hour difference in date time in PHP Method
  • php file upload related configuration tutorial

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1000762.htmlTechArticlephp socket-related 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...
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