Summary of socket series functions in php

Source: Internet
Author: User

Summary of socket series functions in php

This article lists all functions related to socket in PHP. Before using the following functions, make sure that your socket has been opened. If you have not opened the socket, edit your php. ini file and remove the comments (semicolons) in the following line ):

The Code is as follows:

Extension = php_sockets.dll

If you cannot remove the annotation, use the following code to load the extension Library:

The Code is as follows:

  

If (! Extension_loaded ('buckets ')){

If (strtoupper (substr (PHP_ OS, 3) = "WIN "){

Dl ('php _ sockets. dll ');

} Else {

Dl ('ets ETS. so ');

}

}

If you do not know whether your socket is enabled, you can use the phpinfo () function to determine whether the socket is enabled. You can check the phpinfo information to check whether the socket is enabled.

Php socket related functions are as follows:

The Code is as follows:

Socket_accept () accepts a Socket connection

Socket_bind () binds the socket to an IP address and port.

Socket_clear_error () clears socket errors or the final error code

Socket_close () closes a socket Resource

Socket_connect () starts a socket connection

Socket_create_listen () opens a socket listener on the specified port.

Socket_create_pair () generates a pair of identical sockets into an array.

Socket_create () generates a socket, which is equivalent to the data structure of a socket.

Socket_get_option () obtain the socket option

Socket_getpeername () obtains the IP address of a remote host similar to that of a remote host.

Socket_getsockname () gets the IP address of the local socket

Socket_iovec_add () Add a new vector to a scattered/aggregated Array

Socket_iovec_alloc () This function creates an iovec data structure that can send and receive read/write data.

Socket_iovec_delete () deletes an allocated iovec

Socket_iovec_fetch () returns the data of the specified iovec resource.

Socket_iovec_free () releases an iovec resource.

Socket_iovec_set () sets the new value of iovec data

Socket_last_error () obtains the final error code of the current socket.

Socket_listen () listens to all connections from the specified socket

Socket_read () reads data of the specified length

Socket_readv () reads data from scattered/aggregate Arrays

Socket_recv () ends data from the socket to the cache

Socket_recvfrom () accepts data from the specified socket. If no value is specified, the current socket is used by default.

Socket_recvmsg () receives messages from iovec

Socket_select () multi-path selection

Socket_send () This function sends data to the connected socket

Socket_sendmsg () sends a message to the socket

Socket_sendto () sends a message to the socket of the specified address

Socket_set_block () is set to block mode in socket

Set the socket in socket_set_nonblock () to non-block mode.

Socket_set_option () sets socket options

The socket_shutdown () function allows you to close the read, write, or specified socket

Socket_strerror () returns a detailed error of the specified error number

Socket_write () writes data to the socket Cache

Socket_writev () writes data to a distributed/aggregate Array

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.