Jump to content
Sign in to follow this  
Nova

Servers and Clients

Recommended Posts

Firslty tnx a million for the Tcp/Ip dll Larry its amazing....

Im finding great uses for it....I no longer have to use netcat to listen on ports or to send infomation to sockets

Anyways I was wondering if one can send and recieve varibles with TCPSend and TCPRecieve.

I have a situation where I have a server running constantly on my main computer and a client connects to it from another computer on my network. I want the client to send the full name of the computer its running on.

If I was sending infomation I know like for example the message "Helo" from my client to my server I would use do this on my client.

DLLCall( "au3xtra.dll", "int", "TCPSend", "int", $socket, "str", "Helo")

and on this on my server inside a While 1 Wend loop

$rec = DLLCall("au3xtra.dll","int","TCPRecv", "int", $socket, "str", "", "int", 512 ) 

If $ret[2] = "Helo" Then
   Msgbox(0,"Alert","Client said helo")
EndIf

I cant aply the same logic to my situation.......The following wont work becasue I cant tell it to alert me about infomation when it dosent know if it has recieved it or not.

If $ret[2] = $Var Then
   Msgbox(0,"Alert","Computer Name =" & $ret[2])
EndIf

Heres is my edited version of Larrys sample client to help explain my problem.

#include <GUIConstants.au3>

$Computer_Name = @ComputerName

DLLCall("au3xtra.dll","int","TCPStartUp")
$socket = DLLCall("au3xtra.dll","int","TCPConnect", "str", @IPAddress1, "int", 65432 )
If @ERROR Or $socket[0] < 0 Then
    Exit
ElseIf
    DLLCall( "au3xtra.dll", "int", "TCPSend", "int", $socket, "str", $Computer_Name)
Endif    
$socket = $socket[0]

$GOOEY = GUICreate("my client - Server Connected",300,200)
GUISetState()

While 1
   $msg = GUIGetMsg()
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop

    $ret = DLLCall("au3xtra.dll","int","TCPRecv", "int", $socket, "str", "", "int", 512 ) 

    If $ret[2] = "~~rejected" Then
        ExitLoop
    EndIf

    If $ret[0] < 0 Then ExitLoop
WEnd

Func OnAutoItExit()
   DLLCall( "au3xtra.dll", "int", "TCPSend", "int", $socket, "str", "Client Disconnected" )
   DLLCall( "au3xtra.dll", "int", "TCPCloseSocket", "int", $socket )
   DLLCall( "au3xtra.dll", "int", "TCPShutDown")
EndFunc
Edited by Nova

Share this post


Link to post
Share on other sites

Hi Nova, im really interesting in how your tcp/ip communucation works. Im would like to make a server/client to, witch i can send information between them. I guess thats possible with that dll.

Ive read what you posted, and im quite familiure with the code, i do understand the most of it. If its okay, i would like to se an example of your server/client, as simple as possible, so i have a change of understanding it. I need the dll file to test it, so i was kind of hoping you could make a zip/rar file, witch i can take a look at?

Best regards Freekill...

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...