Jump to content

UDP network question


Recommended Posts

Ive been looking through the help file at the udp network functions and from what i have seen its possible to specify the destination port, but not the source port, I am trying to connect to my game server and recieve a status message from it. So i was wondering if anyone could tell me how to set the sourceport, thnx in advance

Edited by death pax
Link to comment
Share on other sites

It appears that UDPBind() does what you're looking for. Helpfile info for UDPBind: Create a socket bound to an incoming connection.

Your destination port would then be declared with UDPOpen(), which says this: Open a socket connected to an existing server.

Edited by greenmachine
Link to comment
Share on other sites

heres my code:

#include <Array.au3>
$IP_Server = "66.148.81.124"

UDPStartup()
$socket=UDPBind(@IPAddress2,2000)
_ArrayDisplay ( $socket, "Server" )
If $Socket = -1 Then Exit
$sendsocket=UDPOpen($IP_Server,9978)
_ArrayDisplay ( $sendsocket, "Client" )
If $sendSocket = -1 Then Exit
    
$bytes=UdpSend($sendsocket,"/info/")
msgbox(1,"bytes",$bytes)
while 1
    $data=UDPRecv($socket,100)
    If $data <> "" Then
        ConsoleWrite($data)
    EndIf
    sleep(100)      
WEnd
Func OnAutoItExit()
    UDPCloseSocket($socket)
    UDPCloseSocket($sendsocket)
    UDPShutdown()
EndFunc

ive checked this from packet sniffer and its still sending that data on a random port, in this case it was port 2222

x.x

Link to comment
Share on other sites

I'm interested in what game you're talking about, because I've done some

small tests with a game myself and I'm thinking of putting them on my fileman...

I have a question about this as well.... Is it possible to recieve game packets analize them and redirect them back to the appropiate port with AutoIT? I would really like to analize some information before it hits the game client on my machine.

[quote] Gilbertson's Law: Nothing is foolproof to a sufficiently talented fool.Sandro Alvares: Flaxcrack is please not noob! i can report you is stop stupid. The Post[/quote]I made this: FWD & MD5PWD()

Link to comment
Share on other sites

probably not without c++

and more on the point, does anyone know how to set the source port?

UDPBind

--------------------------------------------------------------------------------

Create a socket bound to an incoming connection.

;SERVER!! Start Me First !!!!!!!!!!!!!!!
$g_IP = "127.0.0.1"

; Start The UDP Services
;==============================================
UDPStartUp()

; Create a Listening "SOCKET"
;==============================================
$socket = UDPBind($g_IP, 65432)
If @error <> 0 Then Exit

Taken from the help file.

[quote] Gilbertson's Law: Nothing is foolproof to a sufficiently talented fool.Sandro Alvares: Flaxcrack is please not noob! i can report you is stop stupid. The Post[/quote]I made this: FWD & MD5PWD()

Link to comment
Share on other sites

Are you trying to send messages to the to the script within the script? I am not sure what you are doing. The reason it may not be working if you are in fact trying to do this is because the UDPBind () and the UDPSend() don't seem to have the same IP or port number. This is obvious, but i thought i just might point it out. Is there another script you are also using?

Here is a version that works if you are just trying to send UDP packets to the script itself:

#include <Array.au3>
;~ $IP_Server = "66.148.81.124"
$IP_Server = @IPAddress1

UDPStartup()
$socket=UDPBind(@IPAddress1,2000)
_ArrayDisplay ( $socket, "Server" )
If $Socket = -1 Then Exit
;~ $sendsocket=UDPOpen($IP_Server,9978)
$sendsocket=UDPOpen($IP_Server,2000)
_ArrayDisplay ( $sendsocket, "Client" )
If $sendSocket = -1 Then Exit
    
$bytes=UdpSend($sendsocket,"/info/")
msgbox(1,"bytes",$bytes)
while 1
    $data=UDPRecv($socket,100)
    If $data <> "" Then
        ConsoleWrite($data)
    EndIf
;~   sleep(100)     
WEnd
Func OnAutoItExit()
    UDPCloseSocket($socket)
    UDPCloseSocket($sendsocket)
    UDPShutdown()
EndFunc

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

No, this is an external game server. the script would send \info\ to the game server, then the server should send back the response on the same port number that the script sent the \info\ on (provided it is within the the port range 2000-2500 or something like that), this is why i need to designate the source port to use

Edited by death pax
Link to comment
Share on other sites

Because that is what protocol the game uses, its not like i can change it

I am not absolutely sure about this, but I think you are up against the UDP spec, as implemented in Windows' IP stack. UDP being a connectionless "packet lite" kind of protocol uses any send port of opportunity by design, IIRC. Controlling the source port might be equivelent to writing a new IP stack. :o

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

whats an IP stack?

The software modules that handle the various layers of the OSI seven layer model. The whole thing is the "TCP/IP Stack", and layers three and below are the "IP stack". Port addressing is actualy higher than layer three and so I should have said "TCP/IP Stack".

UDP ports are at layer four, and the source port is an optional field.

My point was that the source port is usually considered irrelevant in UDP (of course the destination port is critical). I have not used AutoIT UDP capabilities at all, but assuming it uses calls to Windows' included TCP/IP stack, you may not have any control or access to UDP source ports. I'm not an expert though, and always ready to be corrected.

:o

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...