Sign in to follow this  
Followers 0
MuffettsMan

tcp socket connections dealing with disconnects / reconnects

3 posts in this topic

I have created a rather lengthy tcp server / socket scripts that work great except for the fact that if the client ever disconnects.... i have to kill the server and restart everything (been dealing with it for months and is now just quite annoying)

should the server be able to tell if the client disconnected or should the client be sending a disconnect request to the server? My conern with the lather is what if the network cable was simply unplugged... seems like its the server that needs to keep track of the connections, however if i throw a If $ConnectedSocket < 0 ; (client disconnected) in the top of my script it... the value of If $ConnectedSocket never changed even when my client gracefully or hard disconnects >.<

I assume the server needs to check the validty of all accepted connections? or should $ConnectedSocket be expected to change to -1 every time all clients have disconnected?

any help is greatly appreciated as i'm ripping my hair out here >.<


Don't let that status fool you, I am no advanced memeber!

Share this post


Link to post
Share on other sites



alittle bit more information...

When a client connects...

TCP 192.168.0.5:33892 0.0.0.0:0 LISTENING

TCP 192.168.0.5:33892 68.90.109.152:1432 ESTABLISHED

When the client is closed...

TCP 192.168.0.5:33892 0.0.0.0:0 LISTENING

TCP 192.168.0.5:33892 68.90.109.152:1432 CLOSE_WAIT

So i guess $ConnectedSocket keeps a value because the socket is in fact still open... just in a CLOSE_WAIT status >.<

my stripped down code if its of any help...

SERVER:

#AutoIt3Wrapper_run_debug_mode=Y

;SERVER!! Start Me First !!!!!!!!!!!!!!!
#include <GUIConstants.au3>
#include <Array.au3>

; Set Some reusable info
Dim $SendHotkey
; Set your Public IP address (@IPAddress1) here.
Dim $szIPADDRESS = @IPAddress1
Dim $nPORT = 33892


; Start The TCP Services
;==============================================
TCPStartUp()

; Create a Listening "SOCKET".
;   Using your IP Address and Port 33891.
;==============================================
$MainSocket = TCPListen($szIPADDRESS, $nPORT)

; If the Socket creation fails, exit.
If $MainSocket = -1 Then Exit


; Create a GUI for messages
;==============================================
Dim $GOOEY = GUICreate("My Server (IP: " & $szIPADDRESS & ")",300,200)
Dim $edit = GUICtrlCreateEdit("",10,10,280,180)
GUISetState()


; Initialize a variable to represent a connection
;==============================================
Dim $ConnectedSocket = -1


;Wait for and Accept a connection
;==============================================
Do
    $ConnectedSocket = TCPAccept($MainSocket)
Until $ConnectedSocket <> -1


; Get IP of client connecting
Dim $szIP_Accepted = SocketToIP($ConnectedSocket)

Dim $msg, $recv
; GUI Message Loop
;==============================================
While 1
    TrayTip("Status:", "$ConnectedSocket = " & $ConnectedSocket, 5 , 1)
        If $ConnectedSocket < 0 Then
            TrayTip("DISCONNECTED:", "Client Disconnected ConnectedSocket = -1 attempting to reconnect", 5 , 1)
            Do
                $ConnectedSocket = TCPAccept($MainSocket)
            Until $ConnectedSocket <> -1

        If $ConnectedSocket <> -1 Then
                $szIP_Accepted = SocketToIP($ConnectedSocket)
            ; Someone Connected
            EndIf
        EndIF
   $msg = GUIGetMsg()
   

; Try to receive (up to) 2048 bytes
;----------------------------------------------------------------
    $recv = TCPRecv( $ConnectedSocket, 2048 )
    
; test func
;----------------------------------------------------------------
    If $recv == "test1" Then
        MsgBox(0, "Hmm", "I can't believe it worked...")
    EndIf

; Update the edit control with what we have received
;----------------------------------------------------------------
    If $recv <> "" Then GUICtrlSetData($edit, _
            $szIP_Accepted & " > " & $recv & @CRLF & GUICtrlRead($edit))
WEnd


If $ConnectedSocket <> -1 Then TCPCloseSocket( $ConnectedSocket )

TCPShutDown()

Func Disconnect()
    TrayTip("DISCONNECTED:", "Client Disconnected attempting to reconnect", 5 , 1)
    sleep(5000)
    If $ConnectedSocket <> -1 Then TCPCloseSocket( $ConnectedSocket )
    TCPShutDown()
EndFunc

Func Reconnect()
    TrayTip("DISCONNECTED:", "Client Disconnected Waiting for reconnect", 5 , 1)
    ; Start The TCP Services
    ;==============================================
    TCPStartUp()

    ; Create a Listening "SOCKET".
    ;   Using your IP Address and Port 33891.
    ;==============================================
    $MainSocket = TCPListen($szIPADDRESS, $nPORT)

    ; If the Socket creation fails, exit.
    If $MainSocket = -1 Then Exit

    ;Wait for and Accept a connection
    ;==============================================
    Do
        $ConnectedSocket = TCPAccept($MainSocket)
    Until $ConnectedSocket <> -1


    ; Get IP of client connecting
    Dim $szIP_Accepted = SocketToIP($ConnectedSocket)

    Dim $msg, $recv
EndFunc



; Function to return IP Address from a connected socket.
;----------------------------------------------------------------------
Func SocketToIP($SHOCKET)
    Local $sockaddr = DLLStructCreate("short;ushort;uint;char[8]")

    Local $aRet = DLLCall("Ws2_32.dll","int","getpeername","int",$SHOCKET, _
            "ptr",DLLStructGetPtr($sockaddr),"int*",DLLStructGetSize($sockaddr))
    If Not @error And $aRet[0] = 0 Then
        $aRet = DLLCall("Ws2_32.dll","str","inet_ntoa","int",DLLStructGetData($sockaddr,3))
        If Not @error Then $aRet = $aRet[0]
    Else
        $aRet = 0
    EndIf

    $sockaddr = 0

    Return $aRet
EndFuncoÝ÷ Ø"ÈÔߢ»az׬¶wvÚ!ÛÙÊËaz{ax]ºÛh«­¢+Ø¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì(¥¹±Õ±ÐíMÑÉ¥¹¹ÔÌÐì(¥¹±Õ±Ðí5¥Í¹ÔÌÐì((ÀÌØí±°ô±±=Á¸ ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì¤(I¥½¸MQIP-½U$ÍÑ¥½¸½É´õèÀäÈí½Õµ¹Ñ̹MÑÑ¥¹ÌÀäÈíÌäàÜÈÀäÈí5ä½Õµ¹ÑÌÀäÈí]½ÀäÈí
±¥¹ÑU$¹­á(ÀÌØí½É´ÄôU%
ÉÑ ÅÕ½Ðí½É´ÄÅÕ½Ðì°ÐÈаÌÌÜ°ÄäÌ°ÄÈÔ¤(ÀÌØíMÑÑ¥¹ÍQôU%
Ñɱ
ÉÑQ à°à°ÐÀä°ÌÈĤ)U%
ÑɱMÑIͥ饹 ´Ä°ÀÌØíU%}=
-]%Q ¬ÀÌØíU%}=
-!%!P¤(ÀÌØíMÑÑ¥¹ÌôU%
Ñɱ
ÉÑQ%Ñ´ ÅÕ½Ðí±½°MÑÑ¥¹ÌÅÕ½Ðì¤(ÀÌØí
½¹¹Ñ¥½¹ÍQôU%
Ñɱ
ÉÑQ%Ñ´ ÅÕ½Ðí
½¹¹Ñ¥½¹ÌÅÕ½Ðì¤)U%
ÑɱMÑMÑÑ ´Ä°ÀÌØíU%}M!=¤(ÀÌØí]½ÉɽÕÀôU%
Ñɱ
ÉÑɽÕÀ ÅÕ½Ðí]½ÈÅÕ½Ðì°ÄØ°ÌÈ°ÌäÌ°ØÔ¤(ÀÌØí]½É}UÍÉ9µôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐìÅÕ½Ðì°àà°Ðà°ÄÈÄ°ÈĤ(ÀÌØí]½É}AÍÍݽÉôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐìÅÕ½Ðì°àà°ÜÈ°ÄÈÄ°ÈÄ°  ¥Ñ=H ÀÌØíM}AMM]=I°ÀÌØíM}UQ=!M
I=10¤¤(ÀÌØí]½É}UÍÉ9µ1°ôU%
Ñɱ
ÉÑ1° ÅÕ½ÐíUÍÈ9µèÅÕ½Ðì°ÈаÐà°ØÀ°ÄÜ°    ¥Ñ=H ÀÌØíMM}
9QH°ÀÌØíMM}
9QI%5¤¤(ÀÌØí]½É}AÍÝ1°ôU%
Ñɱ
ÉÑ1° ÅÕ½ÐíAÍÍݽÉèÅÕ½Ðì°ÈаÜÈ°ÔÌ°ÄÜ° ¥Ñ=H ÀÌØíMM}
9QH°ÀÌØíMM}
9QI%5¤¤(ÀÌØí]½É}
¡ÉM±Ñ   ½àôU%
Ñɱ
ÉÑ
½µ¼ ÅÕ½ÐíM±Ð
¡ÉÑÈÅÕ½Ðì°ÈÄØ°Ðà°ÄÀÔ°ÈÔ¤)U%
ÑɱMÑÑ ´Ä°ÅÕ½Ðí
¡ÉÑÈÅñ
¡ÉÑÈÉñ
¡ÉÑÈÍñ
¡ÉÑÈÑñ
¡ÉÑÈÕñ
¡ÉÑÈÙñ
¡ÉÑÈÝñ
¡ÉÑÈáñ
¡ÉÑÈåñ
¡ÉÑÈÄÀÅÕ½Ðì¤(ÀÌØí]½É}á¥Ñ
¡¬ôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½Ðíá¥Ð]½È
±¥¹ÐÅÕ½Ðì°ÈÄØ°ÜÈ°ÄÀÔ°Äܤ(ÀÌØí]½É}1Õ¹ ôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí1Õ¹ ÅÕ½Ðì°ÌÈà°ÔØ°ÜÔ°ÈÔ°À¤)U%
Ñɱ
ÉÑɽÕÀ ÅÕ½ÐìÅÕ½Ðì°´ää°´ää°Ä°Ä¤(ÀÌØí]½ÍɽÕÀôU%
Ñɱ
ÉÑɽÕÀ ÅÕ½Ðí]½ÌÅÕ½Ðì°ÄØ°äØ°ÌäÌ°ØÔ¤(ÀÌØí]½Í}UÍÉ9µôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐìÅÕ½Ðì°àà°ÄÄÈ°ÄÈÄ°ÈĤ(ÀÌØí]½Í}AÍÍݽÉôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐìÅÕ½Ðì°àà°ÄÌØ°ÄÈÄ°ÈÄ°    ¥Ñ=H ÀÌØíM}AMM]=I°ÀÌØíM}UQ=!M
I=10¤¤(ÀÌØí1°ÄôU%
Ñɱ
ÉÑ1° ÅÕ½ÐíUÍÈ9µèÅÕ½Ðì°ÈаÄÄÈ°ØÀ°ÄÜ°  ¥Ñ=H ÀÌØíMM}
9QH°ÀÌØíMM}
9QI%5¤¤(ÀÌØí1°ÈôU%
Ñɱ
ÉÑ1° ÅÕ½ÐíAÍÍݽÉèÅÕ½Ðì°ÈаÄÌØ°ÔÌ°ÄÜ°   ¥Ñ=H ÀÌØíMM}
9QH°ÀÌØíMM}
9QI%5¤¤(ÀÌØí]½Í}
¡ÉM±Ñ   ½àôU%
Ñɱ
ÉÑ
½µ¼ ÅÕ½ÐíM±Ð
¡ÉÑÈÅÕ½Ðì°ÈÄØ°ÄÄÈ°ÄÀÔ°ÈÔ¤)U%
ÑɱMÑÑ ´Ä°ÅÕ½Ðí
¡ÉÑÈÅñ
¡ÉÑÈÉñ
¡ÉÑÈÍñ
¡ÉÑÈÑñ
¡ÉÑÈÕñ
¡ÉÑÈÙñ
¡ÉÑÈÝñ
¡ÉÑÈáñ
¡ÉÑÈåñ
¡ÉÑÈÄÀÅÕ½Ðì¤(ÀÌØí]½Í}á¥Ñ
¡¬ôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½Ðíá¥Ð]½È
±¥¹ÐÅÕ½Ðì°ÈÄØ°ÄÌØ°ÄÀÔ°Äܤ(ÀÌØí]½Í}1Õ¹ ôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí1Õ¹ ÅÕ½Ðì°ÌÈà°ÄÈÀ°ÜÔ°ÈÔ°À¤)U%
Ñɱ
ÉÑɽÕÀ ÅÕ½ÐìÅÕ½Ðì°´ää°´ää°Ä°Ä¤(ÀÌØí]½Ñ}ɽÕÀôU%
Ñɱ
ÉÑɽÕÀ ÅÕ½Ðí]½ÐÅÕ½Ðì°ÄØ°ÄØÀ°ÌäÌ°ØÔ¤(ÀÌØí]½Ñ}UÍÉ9µôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐìÅÕ½Ðì°àà°ÄÜØ°ÄÈÄ°ÈĤ(ÀÌØí]½Ñ}AÍÍݽÉôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐìÅÕ½Ðì°àà°ÈÀÀ°ÄÈÄ°ÈÄ°    ¥Ñ=H ÀÌØíM}AMM]=I°ÀÌØíM}UQ=!M
I=10¤¤(ÀÌØí1°ÌôU%
Ñɱ
ÉÑ1° ÅÕ½ÐíUÍÈ9µèÅÕ½Ðì°ÈаÄÜØ°ØÀ°ÄÜ°  ¥Ñ=H ÀÌØíMM}
9QH°ÀÌØíMM}
9QI%5¤¤(ÀÌØí1°ÐôU%
Ñɱ
ÉÑ1° ÅÕ½ÐíAÍÍݽÉèÅÕ½Ðì°ÈаÈÀÀ°ÔÌ°ÄÜ°   ¥Ñ=H ÀÌØíMM}
9QH°ÀÌØíMM}
9QI%5¤¤(ÀÌØí]½Ñ}
¡ÉM±Ñ   ½àôU%
Ñɱ
ÉÑ
½µ¼ ÅÕ½ÐíM±Ð
¡ÉÑÈÅÕ½Ðì°ÈÄØ°ÄÜØ°ÄÀÔ°ÈÔ¤)U%
ÑɱMÑÑ ´Ä°ÅÕ½Ðí
¡ÉÑÈÅñ
¡ÉÑÈÉñ
¡ÉÑÈÍñ
¡ÉÑÈÑñ
¡ÉÑÈÕñ
¡ÉÑÈÙñ
¡ÉÑÈÝñ
¡ÉÑÈáñ
¡ÉÑÈåñ
¡ÉÑÈÄÀÅÕ½Ðì¤(ÀÌØí]½Ñ}á¥Ñ
¡¬ôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½Ðíá¥Ð]½È
±¥¹ÐÅÕ½Ðì°ÈÄØ°ÈÀÀ°ÄÀÔ°Äܤ(ÀÌØí]½Ñ}1Õ¹ ôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí1Õ¹ ÅÕ½Ðì°ÌÈà°ÄàаÜÔ°ÈÔ°À¤)U%
Ñɱ
ÉÑɽÕÀ ÅÕ½ÐìÅÕ½Ðì°´ää°´ää°Ä°Ä¤(ÀÌØí]½Õ}ɽÕÀôU%
Ñɱ
ÉÑɽÕÀ ÅÕ½Ðí]½ÔÅÕ½Ðì°ÄØ°ÈÌÈ°ÌäÌ°ØÔ¤(ÀÌØí]½Õ}UÍÉ9µôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐìÅÕ½Ðì°àà°ÈÐà°ÄÈÄ°ÈĤ(ÀÌØí]½Õ}AÍÍݽÉôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐìÅÕ½Ðì°àà°ÈÜÈ°ÄÈÄ°ÈÄ°    ¥Ñ=H ÀÌØíM}AMM]=I°ÀÌØíM}UQ=!M
I=10¤¤(ÀÌØí1°ÔôU%
Ñɱ
ÉÑ1° ÅÕ½ÐíUÍÈ9µèÅÕ½Ðì°ÈаÈÐà°ØÀ°ÄÜ°  ¥Ñ=H ÀÌØíMM}
9QH°ÀÌØíMM}
9QI%5¤¤(ÀÌØí1°ØôU%
Ñɱ
ÉÑ1° ÅÕ½ÐíAÍÍݽÉèÅÕ½Ðì°ÈаÈÜÈ°ÔÌ°ÄÜ°   ¥Ñ=H ÀÌØíMM}
9QH°ÀÌØíMM}
9QI%5¤¤(ÀÌØí]½Õ}
¡ÉM±Ñ   ½àôU%
Ñɱ
ÉÑ
½µ¼ ÅÕ½ÐíM±Ð
¡ÉÑÈÅÕ½Ðì°ÈÄØ°ÈÐà°ÄÀÔ°ÈÔ¤)U%
ÑɱMÑÑ ´Ä°ÅÕ½Ðí
¡ÉÑÈÅñ
¡ÉÑÈÉñ
¡ÉÑÈÍñ
¡ÉÑÈÑñ
¡ÉÑÈÕñ
¡ÉÑÈÙñ
¡ÉÑÈÝñ
¡ÉÑÈáñ
¡ÉÑÈåñ
¡ÉÑÈÄÀÅÕ½Ðì¤(ÀÌØí]½Õ}á¥Ñ
¡¬ôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½Ðíá¥Ð]½È
±¥¹ÐÅÕ½Ðì°ÈÄØ°ÈÜÈ°ÄÀÔ°Äܤ(ÀÌØí]½Õ}1Õ¹ ôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí1Õ¹ ÅÕ½Ðì°ÌÈà°ÈÔØ°ÜÔ°ÈÔ°À¤(ÀÌØíM¹-åÍ    ÕÑѽ¸ôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½ÐíM¹-åÌÅÕ½Ðì°ÄÜØ°ÌÀаÜÔ°ÈÔ°À¤(ÀÌØí-¥±±   ÕÑѽ¸ôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí-¥±°]½ÅÕ½Ðì°ÌÈà°ÈäØ°ÜÔ°ÈÔ°À¤)U%
Ñɱ
ÉÑɽÕÀ ÅÕ½ÐìÅÕ½Ðì°´ää°´ää°Ä°Ä¤)U%
Ñɱ
ÉÑQ%Ñ´ ÅÕ½ÐìÅÕ½Ðì¤)U%MÑMÑÑ¡M]}M!=¤(¹I¥½¸9-½U$ÍÑ¥½¸((ìMÑÉÐQ¡Q
@MÉÙ¥Ì(ìôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô)Q
AMÑÉÑUÀ ¤((ìMÐM½µÉÕͱ¥¹¼(ì´´´´´´´´´´´´´´´´´´´´´´´´´´)¥´ÀÌØíÍéMÉÙÉAô
½µÁÕÑÉ9µ(ìMÐÀÌØíÍé%AIMLѼݡÉÙÈÑ¡MIYH¥Ì¸]Ý¥±°¡¹A¹µ¥¹Ñ¼¸%@ÉÍÌ(쥴ÀÌØíÍé%AIMLôQ
A9µQ½%@ ÀÌØíÍéMÉÙÉA¤)¥´ÀÌØíÍé%AIMLôÅÕ½ÐìÜĸäܸà̸ÜÐÅÕ½Ðì)¥´ÀÌØí¹A=IPôÌÌàäÈ(((ì%¹¥Ñ¥±¥éÙÉ¥±Ñ¼ÉÁÉ͹н¹¹Ñ¥½¸(ìôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô)¥´ÀÌØí
½¹¹ÑM½­Ðô´Ä(((íÑѵÁÐѼ½¹¹ÐѼMIYHÐ¥ÑÌ%@¹A=IPÌÌàäÄ(ìôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô(ÀÌØí
½¹¹ÑM½­ÐôQ
A
½¹¹Ð ÀÌØíÍé%AIML°ÀÌØí¹A=IP¤(()¥´ÀÌØíÍéÑ((ì%ѡɥ̸Éɽȸ¸¸Í¡½Ü¥Ð)%ÉɽÈQ¡¸(5Í ½à ÐÄÄÈ°ÅÕ½ÐíÉɽÈÅÕ½Ðì°ÅÕ½ÐíQ
A
½¹¹Ð¥±Ý¥Ñ ]MÉɽÈèÅÕ½ÐìµÀìÉɽȤ(ì%ѡɥ̹¼Éɽȱ½½À¸¥¹ÁÕѽà½ÈÑ(ìѼ͹ѼѡMIYH¸)±Í(í1½½À½ÉÙÈÍ­¥¹½ÈÑѼ͹ѼѡMIYH(((ì
ÉÑÕ¹¥ÅÕ±¥µ¥ÑÈÑ¡ÐÑ¡ÍÉÙȸÍÁ±¥Ð¥¹ÍÐ(ÀÌØí°ôÌäì¨Ìäì)]¡¥±Ä(ÀÌØíµÍôU%Ñ5Í ¤)M±Ð(%
ÍÀÌØíµÍôÀÌØíU%}Y9Q}
1=M($%Q
A
±½ÍM½­Ð ÀÌØí
½¹¹ÑM½­Ð¤ì
±½Íѡͽ­ÐѼѡÍÉÙÈ($%Q
AM¡Õѽݸ ¤ì¥¹¥Ñ¥±¥éÑ¡Q
@չѥ½¹Ì½±¥ÉÉä($%á¥Ð()
ÍÀÌØíµÍôÀÌØíM¹-åÍ    ÕÑѽ¸($%]¡¥±ÀÌØíµÍ±ÐìÐìÀÌØí-¥±±   ÕÑѽ¸($$$ÀÌØíµÍôU%Ñ5Í ¤($%M±Ð(($%
Í}%ÍAÉÍÍ ÅÕ½ÐìÜÄÅÕ½Ðì°ÀÌØí±°¤ìÈչѥ½¸-ä(]¡¥±}%ÍAÉÍÍ ÅÕ½ÐìÜÄÅÕ½Ðì°ÀÌØí±°¤(ì¼¹½Ñ¡¥¹(]¹(Q
AM¹ ÀÌØí
½¹¹ÑM½­Ð°ÅÕ½ÐíM9©ÈÅÕ½Ðì¤($%
ͱÍ($$%ͱÀ ÄÀ¤($%¹M±Ð($%]¹(%¹M±Ð()]¹()¹%

Don't let that status fool you, I am no advanced memeber!

Share this post


Link to post
Share on other sites

ignore this... i'm an idiot....

throwing something like this in the servers loop....

; If the receive failed with @error then the socket has disconnected
;----------------------------------------------------------------
    If @error Then
    ; MsgBox(0, "Hmm", "Client Disconnected?!")
        TCPCloseSocket( $ConnectedSocket )
        TCPShutDown()
        Reconnect()
    EndIf

and the reconnect function at the bottom....

Func Reconnect()
    TrayTip("DISCONNECTED:", "Client Disconnected Waiting for reconnect", 5 , 1)
; Start The TCP Services
;==============================================
    TCPStartUp()

; Create a Listening "SOCKET".
;   Using your IP Address and Port 33891.
;==============================================
    $MainSocket = TCPListen($szIPADDRESS, $nPORT)

; If the Socket creation fails, exit.
    If $MainSocket = -1 Then Exit

;Wait for and Accept a connection
;==============================================
    $ConnectedSocket = -1
    Do
        $ConnectedSocket = TCPAccept($MainSocket)
    Until $ConnectedSocket <> -1


; Get IP of client connecting
    Dim $szIP_Accepted = SocketToIP($ConnectedSocket)

    Dim $msg, $recv
EndFunc

seems to be working GRREEEAAATTT :)


Don't let that status fool you, I am no advanced memeber!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0