dann0 Posted August 4, 2009 Share Posted August 4, 2009 I'm having trouble reading data from a unix socket. i can create the socket and the connection ok and sending data is no problem, but when i try to read or recv the script does not return, if i set the socket to non_blocking i get 'Resource temporarily unavailable'. the socket file i connect to is created by vlc (Video Lan Client) v1.0.1 and my OS is Xubuntu 9.04. my code is $socket = socket_create(AF_UNIX, SOCK_STREAM, 0) or die('socket not created'); socket_set_nonblock($socket); $conn = socket_connect($socket, '/home/rage/smelly.sock')or die('connection not created'); $msg = "playlist"; $len = strlen($msg); $byt = socket_send($socket,$msg,$len,0); print_r( $byt.' bytes successfully sent to socket ('.$socket.')'.PHP_EOL); if($buf = socket_read($socket, 4)){ print_r($buf.PHP_EOL); }else{ $err = socket_last_error($socket); $errormsg = socket_strerror($err); print_r( 'failure on recv'.$errormsg.PHP_EOL); } socket_close($socket); can anyone see the problem with this? Link to comment https://forums.phpfreaks.com/topic/168867-socket_read-unix-socket/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.