vivendi Posted May 5, 2007 Share Posted May 5, 2007 Hello, i want to use the socket functions of php but i have a problem with socket_recv(). I have a server running on a computer. This server just waits for a connection. So i created a file, index.php, with code that connects to that server with the socket functions of php. When the connection is made a immidiatly send a string with the php function socket_send(), the server reacts of this succesfully and immidiatly sends a string back. But this is the part where i have problems, cause php doesn't receive anything at all. Anyone an idea what im doing wrong..?? This is my php code so far: <?php $client = array(); $client['server'] = "127.0.0.1"; $client['poort'] = "7070"; if ( !$sock=socket_create ( AF_INET, SOCK_STREAM, SOL_TCP ) ) { die("De socket kon niet worden aangemaakt."); } if ( !socket_connect( $sock, '127.0.0.1', '7070' ) ) { die("Kon geen verbinding maken met de server: <b>".$client['server']."</b>. Misschien fout?"); } $buf = "getlist"; $recvbuf = ""; socket_send ( $sock, $buf, strlen($buf), 0 ); socket_recv ( $sock, $recvbuf, strlen($recvbuf), 0 ); echo "A: ".$recvbuf; ?> Link to comment https://forums.phpfreaks.com/topic/50154-socket_recv-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.