AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Detect socket connection lost (https://forums.alliedmods.net/showthread.php?t=163361)

AoD90 07-29-2011 13:12

Detect socket connection lost
 
I have server which is connecting to socket server...
When socket server goes down my server crushes.
How can I fix this?
Code:

if (socket_change(g_Socket, 1))
    {
        socket_recv(g_Socket, g_Data, 1999)
       
        if(equal(g_Data, "") || equali(g_LastPack, g_Data))
        {
            if(equal(g_Data, "") || g_lpbr == 2)
            {
                socket_close(g_Socket)
                g_LastPack = ""
                g_lpbr = 0
                return PLUGIN_HANDLED
            }else {
                g_lpbr++
            }
        }else {
            g_LastPack = g_Data
        }

I've noticed when I use server on local machine that when connection hangs that g_Data repeats so I used this if g_Data repeats 2 times that means that connection is dead but it doesn't work when I use this plug on hosted server :(


All times are GMT -4. The time now is 01:08.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.