Sign in to follow this  
Followers 0
qwertylol

tcp connection, identifier, string definition

8 posts in this topic

If I connect multiple clients to the same port on the sever side of au3 codes,

do I identify between the clients with the data they send?

the data I send is stored in a variable beforehand right? and it has to be a string?

is the string created with function_string?

$var = String (hello world! this is alpha!)

TCPSend ( mainsocket, $var )

is this right?

Share this post


Link to post
Share on other sites

If I connect multiple clients to the same port on the sever side of au3 codes,

do I identify between the clients with the data they send?

the data I send is stored in a variable beforehand right? and it has to be a string?

is the string created with function_string?

$var = String (hello world! this is alpha!)

TCPSend ( mainsocket, $var )

is this right?

also,

what should I do if I want au3 to connect to a domain name, like google, and send stuff to the search window and click search?

thank you !

Share this post


Link to post
Share on other sites

also,

what should I do if I want au3 to connect to a domain name, like google, and send stuff to the search window and click search?

thank you !

this might give you hints ....

#include <IE.au3>

_GoogleSearch("autoit beta")

Func _GoogleSearch($sString)
    $sString = StringReplace($sString, " ", "+")
    ShellExecute("www.google.com/search?q=" & $sString) 
EndFunc

Share this post


Link to post
Share on other sites

If I connect multiple clients to the same port on the sever side of au3 codes,

do I identify between the clients with the data they send?

the data I send is stored in a variable beforehand right? and it has to be a string?

is the string created with function_string?

$var = String (hello world! this is alpha!)

TCPSend ( mainsocket, $var )

is this right?

There can be multiple sockets on the same port, each time you use tcpconnect() it shoudl give you a unique one.

Share this post


Link to post
Share on other sites

does it mean that the tcp functions themselves grants no way where the connection it from, and I have to find out what my ip is and include it in my "data" to the server, and vice versa,

also, I have to start a listening socket on both side to talk to each other right ?

Share this post


Link to post
Share on other sites

humm don't quite understand you... but i'll say yes. Have you read the sample in the help file yet? You may find this snippet helpfull-

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_ptr",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
EndFunc

Which returns the IP adress from the socket

Share this post


Link to post
Share on other sites

humm don't quite understand you... but i'll say yes. Have you read the sample in the help file yet? You may find this snippet helpfull-

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_ptr",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
EndFunc

Which returns the IP adress from the socket

um, what is a structure?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

um, what is a structure?

That is irrelevant for now. Don't look inside the function, only learn how to use it. Edited by Manadar

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