|
PHP5中文手册
socket_recvfrom(PHP 4 >= 4.0.7, PHP 5) socket_recvfrom — Receives data from a socket whether or not it is connection-oriented 说明
int socket_recvfrom
( resource $socket
, string &$buf
, int $len
, int $flags
, string &$name
[, int &$port
] )
The socket_recvfrom() function receives len bytes of data in buf from name on port port (if the socket is not of type AF_UNIX) using socket . socket_recvfrom() can be used to gather data from both connected and unconnected sockets. Additionally, one or more flags can be specified to modify the behaviour of the function. The name and port must be passed by reference. If the socket is not connection-oriented, name will be set to the internet protocol address of the remote host or the path to the UNIX socket. If the socket is connection-oriented, name is NULL. Additionally, the port will contain the port of the remote host in the case of an unconnected AF_INET or AF_INET6 socket. 参数
返回值socket_recvfrom() returns the number of bytes received, or -1 if there was an error. The actual error code can be retrieved by calling socket_last_error(). This error code may be passed to socket_strerror() to get a textual explanation of the error. 范例
Example#1 socket_recvfrom() example
<?php This example will initiate an UDP socket on port 1223 of 127.0.0.1 and print at most 12 characters received from a remote host. 更新日志
|