Jump to content

Multi client server


Recommended Posts

Has anyone created a server which adcepts multiple clients using larry au3xtra.dll ?

A few months ago I was playing with the new Tcp function's Larry's DLL offered and altho I created quite a few client/server gui's I could never manage to get more than 1 client to connect to a server !

Ive been really busy latly and havnt been around much, but once again my intrest has been sparked by the idea of creating a multi client server !

I wish to make a handy network tool!

Has anyone got an sample code demonistrating a server that adcepts more than one client ??? that they would like to share ???

Link to comment
Share on other sites

where'd my post go? i posted a server 3+ hours ago.... well here it is the server doesn't forward messages to all clients or send anything but its here

#include <GUIConstants.au3>

DllCall("au3xtra.dll", "int", "TCPStartUp")

$MainSocket = DllCall("au3xtra.dll", "int", "TCPListen", "str", "127.0.0.1", "int", 81, "int", 100)
If @error = 1 Then Error()
$MainSocket = $MainSocket[0]

Dim $Userlist
Dim $socket[1]
$socket[0] = 0

GUICreate("Server", 300, 300)
$Edit = GUICtrlCreateEdit(@TAB & @TAB & "Server started." & @CRLF, 0, 0, 300, 300)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    
    For $i = 1 To $socket[0]
        $ret = DllCall("au3xtra.dll", "int", "TCPRecv", "int", $socket[$i], "str", "", "int", 500)
        
        If $ret[0] > 0 Then
            GUICtrlSetData($Edit, GUICtrlRead($Edit) & @CRLF & $ret[2])
        EndIf
    Next
    
    $NewClient = DllCall("au3xtra.dll", "int", "TCPAccept", "int", $MainSocket)
    If Not @error And $NewClient[0] > 0 Then
        ReDim $socket[UBound($socket) + 1]
        $socket[0] = UBound($socket) - 1
        $socket[UBound($socket) - 1] = $NewClient[0]
        GUICtrlSetData($Edit, GUICtrlRead($Edit) & @CRLF & "New client.")
    EndIf
WEnd
For $i = 1 To $socket[0]
    DllCall( "au3xtra.dll", "int", "TCPCloseSocket", "int", $socket[$i])
Next
DllCall( "au3xtra.dll", "int", "TCPCloseSocket", "int", $MainSocket)
DllCall( "au3xtra.dll", "int", "TCPShutDown")

Func Error()
    MsgBox(16, "Error", "Cannot start server.")
    Exit
EndFunc

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

Tnx a million for your reply Xenogis,

Thats adsactly what I was looking for !!!

Im gona have fun editing this code to suit my needs !

You have given me a great start

Tnx again,

Nova

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...