|
socket_create_pair
Creates a pair of indistinguishable sockets and stores them in an array
(PHP 4 >= 4.0.7, PHP 5)
socket_create_pair() creates two connected and indistinguishable sockets, and stores them in fd. This function is commonly used in IPC (InterProcess Communication). Parameters
ExamplesExample 2292. socket_create_pair() example<?php Example 2293. socket_create_pair() IPC example<?php Code Examples / Notes » socket_create_pairderek
This function wraps socketpair()
thegreatall
There is a syntax error in one of the code samples provided, it should look like this: <?php $sockets = array(); /* Setup socket pair */ if (socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $sockets) === false) { echo "socket_create_pair failed. Reason: ".socket_strerror(socket_last_error()); } /* Send and Recieve Data */ if (socket_write($sockets[0], "ABCdef123\n", strlen("ABCdef123\n")) === false) { echo "socket_write() failed. Reason: ".socket_strerror(socket_last_error($sockets[0])); } if (($data = socket_read($sockets[1], strlen("ABCdef123\n"), PHP_BINARY_READ)) === false) { echo "socket_read() failed. Reason: ".socket_strerror(socket_last_error($sockets[1])); } var_dump($data); /* Close sockets */ socket_close($sockets[0]); socket_close($sockets[1]); ?> |
Change Languagesocket_accept socket_bind socket_clear_error socket_close socket_connect socket_create_listen socket_create_pair socket_create socket_get_option socket_getpeername socket_getsockname socket_last_error socket_listen socket_read socket_recv socket_recvfrom socket_select socket_send socket_sendto socket_set_block socket_set_nonblock socket_set_option socket_shutdown socket_strerror socket_write |