SA-MP Forums Archive
Socket has failed to bind on port - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Socket has failed to bind on port (/showthread.php?tid=675870)



Socket has failed to bind on port - OsmanMalagic - 23.05.2020

Hi, im using a socket for a small application i made for the server.

Now the problem:
First time when i run the server, all is fine, socket is connected and working.
When i restart the server, on my linux for testing im using: kill process id, then restarting it.
But then suddenly when i restart the server again i get this error in the log:

PHP Code:
socket_listen(): Socket has failed to bind on port XXXX 



Re: Socket has failed to bind on port - DRIFT_HUNTER - 23.05.2020

Looks like process is not killed and still running, hence still using given port and when you try to start new process, that port is already taken by previous instance.


Re: Socket has failed to bind on port - OsmanMalagic - 23.05.2020

Quote:
Originally Posted by DRIFT_HUNTER
View Post
Looks like process is not killed and still running, hence still using given port and when you try to start new process, that port is already taken by previous instance.
My server doesn't work when i kill him with Linux command, and my socket is unloaded.
I read on goo gle that I have to open the port on my machine..
"Open a TCP port on your firewall (9014 is the default one)."
My server use 7777 port..


PHP Code:
public OnGameModeExit()
{
    if(
is_socket_valid(SocketID))
    {
        
socket_stop_listen(SocketID);
        
socket_destroy(SocketID);
    }
    return 
1;




Re: Socket has failed to bind on port - OsmanMalagic - 25.05.2020

BUMP


Re: Socket has failed to bind on port - OsmanMalagic - 27.05.2020

BUMP


Re: Socket has failed to bind on port - OsmanMalagic - 28.06.2020

Refresh, the problem is not solved..
socket_listen(): Socket has failed to bind on port 9295
I tried different port, but again same problem.
Is there anybody who have experience with the socket??


Re: Socket has failed to bind on port - Kwarde - 28.06.2020

Use:
Code:
lsof -i:port
To see what process(es) use a certain port (replace port with the actual port, ofc). Maybe it somehow is still used.


Re: Socket has failed to bind on port - OsmanMalagic - 28.06.2020

Quote:
Originally Posted by Kwarde
View Post
Use:
Code:
lsof -i:port
To see what process(es) use a certain port (replace port with the actual port, ofc). Maybe it somehow is still used.
See Attachment


When i restart the server, sometimes this work..
But then suddenly when i restart the server again i get this error in the log


Re: Socket has failed to bind on port - Kwarde - 28.06.2020

Yes, it shows that port 7780 is used by samp03svr. After closing the server (killing the process) you should use that command to see if it's somehow still used.


Re: Socket has failed to bind on port - OsmanMalagic - 28.06.2020

Quote:
Originally Posted by Kwarde
View Post
Yes, it shows that port 7780 is used by samp03svr. After closing the server (killing the process) you should use that command to see if it's somehow still used.
Now when i restart the server using panel, this message pop out in server.log
And also i tried again lsof -i:7780 and nothing happens