Search Webmaster Help and Solution

sockets problem

Hello,
Im recieving the following warning:
Warning: socket_bind() unable to bind address [10048]: Only one usage of each socket address (protocol/network address/port) is normally permitted. in blablaindex.php on line 6
Could not bind to socket

when i run the following script:
PHP Code:  $host = 127.0.0.1;
$port = 12234;
set_time_limit(0);
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die(Could not create socket );
$result = socket_bind($socket, $host, $port) or die(Could not bind to socket );
$result = socket_listen($socket, 3) or die(Could not set up socket listener );
$spawn = socket_accept($socket) or die(Could not accept incoming connection );
$input = socket_read($spawn, 1024) or die(Could not read input );
$input = trim($input);
$output = strrev($input) .  ;
socket_write($spawn, $output, strlen ($output)) or die(Could not write output );
socket_close($spawn);
socket_close($socket); 


Im completely new to socket programming and have no idea whats going wrong. The script is from the intro to socket programming article here on devshed, and im assuming shouldnt churn out any warnings.

Can anyone tell me whats wrong?
phpinfo says sockets are enabled
Im running apache/1.3.24 on windows xp pro

Thanks Hello,
Im recieving the following warning:
Warning: socket_bind() unable to bind address [10048]: Only one usage of each socket address (protocol/network address/port) is normally permitted. in blablaindex.php on line 6
Could not bind to socket

when i run the following script:
PHP Code:  $host = 127.0.0.1;
$port = 12234;
set_time_limit(0);
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die(Could not create socket );
$result = socket_bind($socket, $host, $port) or die(Could not bind to socket );
$result = socket_listen($socket, 3) or die(Could not set up socket listener );
$spawn = socket_accept($socket) or die(Could not accept incoming connection );
$input = socket_read($spawn, 1024) or die(Could not read input );
$input = trim($input);
$output = strrev($input) .  ;
socket_write($spawn, $output, strlen ($output)) or die(Could not write output );
socket_close($spawn);
socket_close($socket); 


Im completely new to socket programming and have no idea whats going wrong. The script is from the intro to socket programming article here on devshed, and im assuming shouldnt churn out any warnings.

Can anyone tell me whats wrong?
phpinfo says sockets are enabled
Im running apache/1.3.24 on windows xp pro

Thanks

View Complete Thread with Replies

Related Items

Query failed: connection to localhost:3354 failed (errno=111, msg=Connection refused).