note 80524 deleted from function.socket-set-option by nlopess
| From: | nlopess@php.net | Date: | Sun, 20 Jan 2008 18:04:49 +0000 |
| Subject: | note 80524 deleted from function.socket-set-option by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-135263@lists.php.net to get a copy of this message | ||
Note Submitter: olamedia at gmail dot com
----
TOO BAD Example!
if (!socket_bind($socket, '127.0.0.1', 1223)) {
echo 'Unable to bind socket: '. socket_strerror(socket_last_error()) . PHP_EOL;
}
$rval = socket_get_option($socket, SOL_SOCKET, SO_REUSEADDR);
I'm spend very much time to found wat I'm doing wrong.
http://www.unixprogram.com/socket/socket-faq.html#faq44
5. What exactly does SO_REUSEADDR do?
This socket option tells the kernel that even if this port is busy (in the TIME_WAIT state), go
ahead and reuse it anyway. If it is busy, but with another state, you will still get an address
already in use error. It is useful if your server has been shut down, and then restarted right away
while sockets are still active on its port. You should be aware that if any unexpected data comes
in, it may confuse your server, but while this is possible, it is not likely.
SO_REUSEADDR MUST CALLED BEFORE BIND else if port is busy bind will not be processed...
give me back my years.... )