From 58e1cb40c6cb0b08d9eddbe64f99304d555eea79 Mon Sep 17 00:00:00 2001 From: Hartmut Holzgraefe Date: Mon, 17 Dec 2001 10:30:32 +0000 Subject: [PATCH] renamed functions and added seletons for missing ones git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@65399 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/sockets.xml | 935 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 804 insertions(+), 131 deletions(-) diff --git a/functions/sockets.xml b/functions/sockets.xml index 03374a26d5..66ea791d6f 100644 --- a/functions/sockets.xml +++ b/functions/sockets.xml @@ -1,5 +1,5 @@ - + Socket functions Sockets @@ -58,28 +58,28 @@ set_time_limit (0); $address = '192.168.1.53'; $port = 10000; -if (($sock = socket (AF_INET, SOCK_STREAM, 0)) < 0) { - echo "socket() failed: reason: " . strerror ($sock) . "\n"; +if (($sock = socket_create (AF_INET, SOCK_STREAM, 0)) < 0) { + echo "socket_create() failed: reason: " . socket_strerror ($sock) . "\n"; } -if (($ret = bind ($sock, $address, $port)) < 0) { - echo "bind() failed: reason: " . strerror ($ret) . "\n"; +if (($ret = socket_bind ($sock, $address, $port)) < 0) { + echo "socket_bind() failed: reason: " . socket_strerror ($ret) . "\n"; } -if (($ret = listen ($sock, 5)) < 0) { - echo "listen() failed: reason: " . strerror ($ret) . "\n"; +if (($ret = socket_listen ($sock, 5)) < 0) { + echo "socket_listen() failed: reason: " . socket_strerror ($ret) . "\n"; } do { - if (($msgsock = accept_connect($sock)) < 0) { - echo "accept_connect() failed: reason: " . strerror ($msgsock) . "\n"; + if (($msgsock = socket_accept($sock)) < 0) { + echo "socket_accept() failed: reason: " . socket_strerror ($msgsock) . "\n"; break; } do { $buf = ''; - $ret = read ($msgsock, $buf, 2048); + $ret = socket_read ($msgsock, $buf, 2048); if ($ret < 0) { - echo "read() failed: reason: " . strerror ($ret) . "\n"; + echo "socket_read() failed: reason: " . socket_strerror ($ret) . "\n"; break 2; } if ($ret == 0) { @@ -87,17 +87,17 @@ do { } $buf = trim ($buf); if ($buf == 'quit') { - close ($msgsock); + socket_close ($msgsock); break 2; } $talkback = "PHP: You said '$buf'.\n"; - write ($msgsock, $talkback, strlen ($talkback)); + socket_write ($msgsock, $talkback, strlen ($talkback)); echo "$buf\n"; } while (true); - close ($msgsock); + socket_close ($msgsock); } while (true); -close ($sock); +socket_close ($sock); ?> ]]> @@ -125,17 +125,17 @@ $service_port = getservbyname ('www', 'tcp'); $address = gethostbyname ('www.php.net'); /* Create a TCP/IP socket. */ -$socket = socket (AF_INET, SOCK_STREAM, 0); +$socket = socket_create (AF_INET, SOCK_STREAM, 0); if ($socket < 0) { - echo "socket() failed: reason: " . strerror ($socket) . "\n"; + echo "socket_create() failed: reason: " . socket_strerror ($socket) . "\n"; } else { - "socket() successful: " . strerror ($socket) . "\n"; + "socket_create() successful: " . socket_strerror ($socket) . "\n"; } echo "Attempting to connect to '$address' on port '$service_port'..."; -$result = connect ($socket, $address, $service_port); +$result = socket_connect ($socket, $address, $service_port); if ($result < 0) { - echo "connect() failed.\nReason: ($result) " . strerror($result) . "\n"; + echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n"; } else { echo "OK.\n"; } @@ -144,16 +144,16 @@ $in = "HEAD / HTTP/1.0\r\n\r\n"; $out = ''; echo "Sending HTTP HEAD request..."; -write ($socket, $in, strlen ($in)); +socket_write ($socket, $in, strlen ($in)); echo "OK.\n"; echo "Reading response:\n\n"; -while (read ($socket, $out, 2048)) { +while (socket_read ($socket, $out, 2048)) { echo $out; } echo "Closing socket..."; -close ($socket); +socket_close ($socket); echo "OK.\n\n"; ?> ]]> @@ -162,39 +162,39 @@ echo "OK.\n\n"; - + - accept_connect + socket_accept Accepts a connection on a socket Description - int accept_connect + int socket_accept resource socket &warn.experimental.func; After the socket socket has been created - using socket, bound to a name with - bind, and told to listen for connections - with listen, this function will accept + using socket_create, bound to a name with + socket_bind, and told to listen for connections + with socket_listen, this function will accept incoming connections on that socket. Once a successful connection is made, a new socket descriptor is returned, which may be used for communication. If there are multiple connections queued on the socket, the first will be used. If there are no pending - connections, accept_connect will block until + connections, socket_accept will block until a connection becomes present. If socket has been made non-blocking using socket_set_blocking or - set_nonblock, an error code will be + socket_set_nonblock, an error code will be returned. The socket descriptor returned by - accept_connect may not be used to accept new + socket_accept may not be used to accept new connections. The original listening socket socket, however, remains open and may be reused. @@ -202,31 +202,31 @@ echo "OK.\n\n"; Returns a new socket descriptor on success, or a negative error code on failure. This code may be passed to - strerror to get a textual explanation of the + socket_strerror to get a textual explanation of the error. See also - bind, - connect, - listen, - socket, + socket_bind, + socket_connect, + socket_listen, + socket_create, socket_get_status, and - strerror. + socket_strerror. - + - bind + socket_bind Binds a name to a socket Description - int bind + int socket_bind resource socket string address int @@ -236,10 +236,10 @@ echo "OK.\n\n"; &warn.experimental.func; - bind binds the name given in + socket_bind binds the name given in address to the socket described by socket, which must be a valid socket - descriptor created with socket. + descriptor created with socket_create. The address parameter is either an IP @@ -257,70 +257,69 @@ echo "OK.\n\n"; Returns zero on success, or a negative error code on - failure. This code may be passed to strerror + failure. This code may be passed to socket_strerror to get a textual explanation of the error. See also - accept_connect, - connect, - listen, - socket, + socket_connect, + socket_listen, + socket_create, socket_get_status, and - strerror. + socket_strerror. - + - close - Closes a file descriptor + socket_close + Closes a socket descriptor Description - bool close + bool soclet_close resource socket &warn.experimental.func; - close closes the file (or socket) descriptor + socket_close closes the file (or socket) descriptor given by socket. - Note that close should not be used on PHP + Note that socket_close should not be used on PHP file descriptors created with fopen, popen, fsockopen, or psockopen; it is meant for sockets created - with socket or - accept_connect. + with socket_create or + socket_accept. Returns &true; on success, or &false; if an error occurs (i.e., socket is invalid). - See also bind, listen, - socket, + See also socket_bind, socket_listen, + socket_create, socket_get_status, and - strerror. + socket_strerror. - + - connect + socket_connect Initiates a connection on a socket Description - int connect + int socket_connect resource socket string address int @@ -328,11 +327,11 @@ echo "OK.\n\n"; - &warn.experimental.func; + &warn.experimental.func; Initiates a connection using the socket descriptor socket, which must be a valid socket - descriptor created with socket. + descriptor created with socket_create. The address parameter is either an IP @@ -350,75 +349,75 @@ echo "OK.\n\n"; Returns zero on success, or a negative error code on - failure. This code may be passed to strerror + failure. This code may be passed to socket_strerror to get a textual explanation of the error. See also - bind, - listen, - socket, + socket_bind, + socket_listen, + socket_create, socket_get_status, and - strerror. + socket_strerror. - + - listen + socket_listen Listens for a connection on a socket Description - int listen + int socket_listen resource socket int backlog - &warn.experimental.func; + &warn.experimental.func; After the socket socket has been created - using socket and bound to a name with - bind, it may be told to listen for incoming + using socket_create and bound to a name with + socket_bind, it may be told to listen for incoming connections on socket. A maximum of backlog incoming connections will be queued for processing. - listen is applicable only to sockets with + socket_listen is applicable only to sockets with type SOCK_STREAM or SOCK_SEQPACKET. Returns zero on success, or a negative error code on - failure. This code may be passed to strerror + failure. This code may be passed to socket_strerror to get a textual explanation of the error. See also - accept_connect, - bind, - connect, - socket, + socket_accept, + socket_bind, + socket_connect, + socket_create, socket_get_status, and - strerror. + socket_strerror. - + - read + socket_read Read from a socket Description - int read + int socket_read resource socket_des string buffer int length @@ -427,9 +426,9 @@ echo "OK.\n\n"; &warn.experimental.func; - The function read reads from socket + The function socket_read reads from socket socket_descreated by the - accept_connect function into + socket_accept function into buffer the number of bytes set by length. Otherwise you can use \n, \t or \0 to end reading. Returns number of bytes that have been read. @@ -439,7 +438,7 @@ echo "OK.\n\n"; - PHP_BINARY_READ - use the system read + PHP_BINARY_READ - use the system socket_read (Default in PHP >= 4.1.0) @@ -452,33 +451,33 @@ echo "OK.\n\n"; See also - accept_connect, - bind, - connect, - listen, - strerror, + socket_accept, + socket_bind, + socket_connect, + socket_listen, + socket_strerror, socket_get_status and - write. + socket_write. - + - socket + socket_create Create a socket (endpoint for communication) Description - int socket + int socket_create int domain int type int protocol - &warn.experimental.func; + &warn.experimental.func; Creates a communication endpoint (a socket), and returns a descriptor to the socket. @@ -502,62 +501,62 @@ echo "OK.\n\n"; Returns a valid socket descriptor on success, or a negative error code on failure. This code may be passed to - strerror to get a textual explanation of the + socket_strerror to get a textual explanation of the error. - For more information on the usage of socket, + For more information on the usage of socket_create, as well as on the meanings of the various parameters, see the Unix man page socket (2). See also - accept_connect, - bind, - connect, - listen, - strerror, and + socket_accept, + socket_bind, + socket_connect, + socket_listen, + socket_strerror, and socket_get_status. - + - strerror + socket_strerror Return a string describing a socket error Description - string strerror + string socket_strerror int errno &warn.experimental.func; - strerror takes as its + socket_strerror takes as its errno parameter the return value of one of the socket functions, and returns the corresponding explanatory text. This makes it a bit more pleasant to figure out why something didn't work; for instance, instead of having to track down a system include file to find out what '-111' means, you - just pass it to strerror, and it tells you + just pass it to socket_strerror, and it tells you what happened. - <function>strerror</function> example + <function>socket_strerror</function> example ]]> @@ -573,26 +572,26 @@ if (($ret = bind ($socket, '127.0.0.1', 80)) < 0) { See also - accept_connect, - bind, - connect, - listen, - socket, and + socket_accept, + socket_bind, + socket_connect, + socket_listen, + socket_create, and socket_get_status. - + - write + socket_write Write to a socket Description - int write + int socket_write resource socket_des string &buffer int length @@ -600,24 +599,698 @@ if (($ret = bind ($socket, '127.0.0.1', 80)) < 0) { &warn.experimental.func; - The function write writes to the socket + The function socket_write writes to the socket socket_des from &buffer the number of bytes set by length. See also - accept_connect, - bind, - connect, - listen, - read, - strerror, and + socket_accept, + socket_bind, + socket_connect, + socket_listen, + socket_read, + socket_strerror, and socket_get_status. + + + socket_fd_alloc + Allocates a new file descriptor set + + + Description + + + resource socket_fd_alloc + + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_fd_free + Deallocates a file descriptor set + + + Description + + + bool socket_fd_free + resource set + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_fd_set + Adds (a) file descriptor(s) to a set + + + Description + + + bool socket_fd_set + resource set + mixed socket + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_fd_clear + Clears (a) file descriptor(s) from a set + + + Description + + + bool socket_fd_clear + resource set + mixed socket + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_fd_isset + Checks to see if a file descriptor is set within the file descrirptor set + + + Description + + + bool socket_fd_isset + resource set + resource socket + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_fd_zero + Clears a file descriptor set + + + Description + + + bool socket_fd_zero + resource set + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_select + Runs the select() system call on the sets mentioned with a timeout specified by tv_sec and tv_usec + + + Description + + + int socket_select + resource read_fd + resource write_fd + resource except_fd + int tv_sec + int + tv_usec + + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_create_listen + Opens a socket on port to accept connections + + + Description + + + resource socket_create_listen + int port + int + backlog + + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_set_nonblock + Sets nonblocking mode for file descriptor fd + + + Description + + + bool socket_set_nonblock + resource socket + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_getsockname + Given an fd, stores a string representing sa.sin_addr and the value of sa.sin_port into addr and port describing the local side of a socket + + + Description + + + bool socket_getsockname + resource socket + string &addr + int + &port + + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_getpeername + Given an fd, stores a string representing sa.sin_addr and the value of sa.sin_port into addr and port describing the remote side of a socket + + + Description + + + bool socket_getpeername + resource socket + string &addr + int + &port + + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_iovec_alloc + ...]) Builds a 'struct iovec' for use with sendmsg, recvmsg, writev, and readv + + + Description + + + resource socket_iovec_alloc + int num_vectors + int + + + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_iovec_fetch + Returns the data held in the iovec specified by iovec_id[iovec_position] + + + Description + + + string socket_iovec_fetch + resource iovec + int iovec_position + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_iovec_set + Sets the data held in iovec_id[iovec_position] to new_val + + + Description + + + bool socket_iovec_set + resource iovec + int iovec_position + string new_val + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_iovec_add + Adds a new vector to the scatter/gather array + + + Description + + + bool socket_iovec_add + resource iovec + int iov_len + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_iovec_delete + Deletes a vector from an array of vectors + + + Description + + + bool socket_iovec_delete + resource iovec + int iov_pos + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_iovec_free + Frees the iovec specified by iovec_id + + + Description + + + bool socket_iovec_free + resource iovec + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_readv + Reads from an fd, using the scatter-gather array defined by iovec_id + + + Description + + + bool socket_readv + resource socket + resource iovec_id + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_writev + Writes to a file descriptor, fd, using the scatter-gather array defined by iovec_id + + + Description + + + bool socket_writev + resource socket + resource iovec_id + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_recv + Receives data from a connected socket + + + Description + + + mixed socket_recv + resource socket + int len + int flags + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_send + Sends data to a connected socket + + + Description + + + int socket_send + resource socket + string buf + int len + int flags + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_recvfrom + Receives data from a socket, connected or not + + + Description + + + int socket_recvfrom + resource socket + string &buf + int len + int flags + string &name + int + &port + + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_sendto + Sends a message to a socket, whether it is connected or not + + + Description + + + int socket_sendto + resource socket + string buf + int len + int flags + string addr + int + port + + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_recvmsg + Used to receive messages on a socket, whether connection-oriented or not + + + Description + + + bool socket_recvmsg + resource socket + resource iovec + array &control + int &controllen + int &flags + string &addr + int + &port + + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_sendmsg + Sends a message to a socket, regardless of whether it is connection-oriented or not + + + Description + + + bool socket_sendmsg + resource socket + resource iovec + int flags + string addr + int + port + + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_getopt + Gets socket options for the socket + + + Description + + + mixed socket_getopt + resource socket + int level + int optname + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_setopt + |array optval) Sets socket options for the socket + + + Description + + + bool socket_setopt + resource socket + int level + int optname + int + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_create_pair + Creates a pair of indistinguishable sockets and stores them in fds. + + + Description + + + bool socket_create_pair + int domain + int type + int protocol + array &fd + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_shutdown + Shuts down a socket for receiving, sending, or both. + + + Description + + + bool socket_shutdown + resource socket + int + how + + + + &warn.experimental.func; + + &warn.undocumented.func; + + + + + + + socket_last_error + Returns/Clears the last error on the socket + + + Description + + + int socket_last_error + resource socket + + + &warn.experimental.func; + + &warn.undocumented.func; + + + +