Hooch Posted September 30, 2005 Posted September 30, 2005 I am playing with a UDP example from the forums, had to modify it and install the latest beta but I got it working Anyways, on the server side, I don't have access to the incoming connections meta data, i.e. the connection IP address. This info would be needed to be able to block IP addresses etc. I know the information is in the packet but that info is not exposed in the functions that are currently available. Am I missing something obvious?
Hooch Posted September 30, 2005 Author Posted September 30, 2005 Heh thanks for the reply Larry, now can you talk to me like I'm stupid please What API....
Hooch Posted October 3, 2005 Author Posted October 3, 2005 Ok I gave that a try Larry, Server: #include <vars.au3> #include <functions.au3> #include <gui.au3> HotKeySet("{F10}", "Quit") UDPStartup() $uServer = UDPBind(@IPAddress1, 31337) If $uServer = -1 Then Exit ; While 1 $uText = UDPRecv($uServer, 100) If $uText <> "" Then $cIP = SOCKET2IP($uServer) MsgBox(0, "IP Address", "client IP: " & $cIP) EndIf WEnd Client: UDPStartup() $uClient = UDPOpen("192.197.4.75", 31337) If $uClient = -1 Then Exit ; While 1 $uStatus = UDPSend($uClient, $PublicIP & ": Hello") sleep(1) WEnd All I am getting is "0" so most likely I am doing something wrong...
Hooch Posted October 3, 2005 Author Posted October 3, 2005 I tried it with the UNBIND socket and also on the UDPRecv... same result... I take it that it worked for you Larry, are you able to post the code you tested it with?
livewire Posted October 3, 2005 Posted October 3, 2005 I may not be understanding you correctly, but from the beta helpfile, can't you just use the return of UDPBind? $array[2] = IP Address -Livewire
/dev/null Posted October 3, 2005 Posted October 3, 2005 I may not be understanding you correctly, but from the beta helpfile, can't you just use the return of UDPBind?$array[2] = IP Address-LivewireLivewire, you're right, the UDP "socket" (which is an array) contains all the information of the connection. That was necessary to get the UDP stuff to work.CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
Hooch Posted October 3, 2005 Author Posted October 3, 2005 Isn't that the IP of the socket you have bound to as the server? What I need is the IP of the incoming connections to the server, not the server itself.
livewire Posted October 3, 2005 Posted October 3, 2005 No...it's the IP of the incomming communication...at least I just tried it and it is...try it. -Livewire Send some data to this... UDPStartup() $socket = UDPBind(@IPAddress1, 20000) ; Change port if u want If @error <> 0 Then Exit While 1 $data = UDPRecv($socket, 5000) If $data <> "" Then MsgBox(0,"Testing","$socket[1] = " & $socket[1] & @CRLF & _ "$socket[2] = " & $socket[2] & @CRLF & _ "$socket[3] = " & $socket[3] & @CRLF) EndIf sleep(100) WEnd Func OnAutoItExit() UDPCloseSocket($socket) UDPShutdown() EndFunc
Hooch Posted October 3, 2005 Author Posted October 3, 2005 Oh well sheesh... ok cool I'll give that a go. One thing I wonder about is multiple connections. I am planning a tool that 1-10 clients will be sending a command as well as periodic keep-alive broadcasts to the server and I wanted to tag each incoming cumunication with it's ip and timestamp from the server side. So... the value of $array[2] = IP Address will be the data about the communication that is currently being processed? I overlooked that as the Ubind is setup prior to our runtime loop so I expected that to be static data from that point.... am I making sense?
Hooch Posted October 3, 2005 Author Posted October 3, 2005 My version of the help file doesn't contain a UDPAccept function....
livewire Posted October 3, 2005 Posted October 3, 2005 That example is modified from the beta helpfile. After you receive data (UDPRecv), I'm assuming $array[2] becomes the IP of the computer that that specific packet came from. -Livewire
Hooch Posted October 3, 2005 Author Posted October 3, 2005 Ok cool then, if that's how it works I am good to go. I'll report back how I make out Ah that is indeed how it works. Nice. Thank you for the info and the replies people
livewire Posted October 3, 2005 Posted October 3, 2005 No prob...I use UDP also...it's good info to know. -Livewire
/dev/null Posted October 3, 2005 Posted October 3, 2005 Isn't that the IP of the socket you have bound to as the server? What I need is the IP of the incoming connections to the server, not the server itself.After a UDPRecv() it's the data of the connecting host.CheersKurtWhat IS an incoming connection for this UDP? I see a "main" socket set using UDPBind() and then just UDPRecv()... I don't see any UDPAccept() that would give you a socket for parsing.LAr.Actually there is no UDPAccept() because there are no "connections" like in TCP. UDPRecv() will just return the incoming data of the last client that sent something. Additionally UDPRecv() it sets the IP addr and port of the incoming "connection", so you can answer to that client. I could not find another way to do it, as there are no established connections for UDP.CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now