note 22200 modified in function.socket-bind by aidan
| From: | aidan@php.net | Date: | Thu, 24 Feb 2005 07:22:11 +0000 |
| Subject: | note 22200 modified in function.socket-bind by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-85466@lists.php.net to get a copy of this message | ||
If you want to reuse address and port, and get rid of error: unable to bind, address already in use,
you have to use socket_setopt (check actual spelling for this function in you PHP verison) before
calling bind:
<?php
if (!@socket_setopt($sock,SOL_SOCKET,SO_REUSEADDR,1)) {
echo "socket_setopt() failed: reason:".
socket_strerror(socket_last_error($sock))."\n";
exit;
}
?>
This solution was found by
Christophe Dirac. Thank you Christophe!
--was--
If you want to reuse address and port, and get rid of error: unable to bind, address already in use,
you have to use socket_setopt (check actual spelling for this function in you PHP verison) before
calling bind:
if (!@socket_setopt($sock,SOL_SOCKET,SO_REUSEADDR,1)) {
echo "socket_setopt() failed: reason:
".socket_strerror(socket_last_error($sock))."\n";
exit;
}
This solution was found by
Christophe Dirac. Thank you Christophe!
http://php.net/manual/en/function.socket-bind.php