Jump to content

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")

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.

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

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

#include <GUIConstants.au3>

$Computer_Name = @ComputerName

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

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

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

    If $ret[0] < 0 Then ExitLoop

Func OnAutoItExit()
   DLLCall( "au3xtra.dll", "int", "TCPSend", "int", $socket, "str", "Client Disconnected" )
   DLLCall( "au3xtra.dll", "int", "TCPCloseSocket", "int", $socket )
   DLLCall( "au3xtra.dll", "int", "TCPShutDown")
Link to post
Share on other sites

Tnx for the reply Lar but I still cant get it too work.

I have attached both my client and my server scripts to this post.

Any chance you'd take a look when you get a minute ?

Also I understand everything in your example scripts adcept the idea of the Rouge Socket, can u plz explain it ?


Link to post
Share on other sites

@tamir how did u make mulitple clients connect to the one server ?

I havent sucessfully figured out a method of doing that yet.

I have seen Syberslugs idea with the clients which only recieve and cannot send.

Can U plz post an example ?

Link to post
Share on other sites

u create an array - Dim $Sockets

and then you accept clients normally but when u accept a new client u add its socket number to the $Sockets array (with ReDim).

to recieve and send messages u need to use the For loop, e.g:

For $i=0 To UBound($Sockets)-1
   $ret = DllCall(*blah blah blah*, Socket: $Sockets[$i])
   If $ret[0] > 0 Then
     ;do something with the messgae

something like that

Link to post
Share on other sites

I was actually revolving such an idea but didnt know how to write it down.

Because you cant manage multiple clients sending infomation to the same sockets you have to have a new socket for every client.

So you set a starting port lets say 4000 and if a client connects to that its used up so u then offer Socket +1 ie 4001 to the next client who wants to connect etc etc

I really dont understand Arrays at all, and ive never used thearray functions.

Any chance u can post a working example of a multi client server?

I learn better by editiing a working example, at least that way I can begin to understand how everything works

Edited by Nova
Link to post
Share on other sites

Don't think so. You can only send strings and numbers.


That´s exactly what files are, isn´t it? You just have to convert it to Hex or something and then send it. Shouldn´t be a big problem.

[quote name='d2hacker88' date='Jan 6 2005, 05:10 PM']Can someone please help me out with autoit like gimme a link on how to use it cause i have no experience with computer languages and i'd like to make a program with autoit in order to empress my computer teacher.[right][snapback]52215[/snapback][/right][/quote]

Link to post
Share on other sites

ZIP files, executables, DLLs, databases, MS Word documents, etc are all binary files.

They are made with machine code and are not readable with a text editor.

And AutoIt can't handle binary files (yet). It can't read, write or send them.

But you can send text files (their contents ofcourse).

Edited by SlimShady
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...