User entfernen und diesen Platz frei geben

  • Moien allerseits.

    Ich schreibe gerade einen chat für unsere klasse. Dieser Chat ist sehr einfach gehalten, aber ich habe ein Problem.

    Wie kann ich es schaffen, wenn ein user disconnectet das dieser Platz wieder frei nützbar wird?

    der quellcode sieht so aus

    Spoiler anzeigen
    [autoit]

    HotKeySet("{ESC}", "Quit"); Press ESC to quit
    #include <Array.au3>
    Global $current_socket = 0
    Global $connected_socket[16]
    Global $tcp_server

    [/autoit] [autoit][/autoit] [autoit]

    $tcp = TCPStartup()
    If $tcp = 0 Then
    MsgBox(16, "Error", "Unable to startup TCP Services!")
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $tcp_server = TCPListen(@IPAddress1, 1777, 16)
    If $tcp_server = -1 Then
    MsgBox(16, "ERROR", "Unable to start listening on port 1777")
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $connected_socket[$current_socket] = TCPAccept($tcp_server)
    If $connected_socket[$current_socket] <> -1 Then
    $current_socket += 1
    EndIf
    For $index = 0 To 15
    $recv = TCPRecv($connected_socket[$index], 9999999)

    If $recv <> "" Then
    For $i = 0 To 15
    TCPSend($connected_socket[$i], "Vom Client: " & $index & @CRLF & "Nachicht: " & $recv & @CRLF)
    Next
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Next
    Sleep(20)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func Quit()
    TCPCloseSocket($tcp_server)
    TCPShutdown()
    Exit
    EndFunc

    [/autoit]

    Kann mir einer helfen?