L
L
LittleFatNinja2015-06-03 20:52:51
PHP
LittleFatNinja, 2015-06-03 20:52:51

PHP socket_bind() - Address already in use?

I have the following sequence of actions:

socket_create();
socket_bind();
socket_accept();
socket_close();

I start this server, as it were, I connect to it, the server shuts down (without cycles). Everything is fine, I
start the server immediately for the second time, but it pops up
PHP Warning:  socket_bind(): unable to bind address [98]: Address already in us

I'm waiting somewhere for 30 seconds (some kind of timeout), I run it again - everything is OK,
but why is that? I close the socket after myself

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-06-03
@LittleFatNinja

When an application dies, the system does not release the socket immediately (by default), it goes into TAIM_AWAIT.
If you want to explicitly indicate that immediately after the socket is closed, it can be opened immediately, you need to specify the SO_REUSEADDR option

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question