Sign in to follow this  
Followers 0
death pax

UDP Help

7 posts in this topic

#1 ·  Posted (edited)

I have a small problem with getting udp working

$g_IP="63.124.142.3"
$g_port=8001
UDPStartup()
$socket=UDpOpen($g_IP,$g_port)
if @Error <> 0 Then 
Msgbox(0,"",@error)
Exit
EndIf
UDpSend($socket,"\status\")

Func OnAutoItExit()
    UDPCloseSocket($socket)
    UDPShutdown()
EndFunc

This all works fine, i checked with a packet analyzer and it indeed was sent, however

how would i go about listening for the response on the same port that this was sent on?

Edited by death pax

Share this post


Link to post
Share on other sites



Anybody?

Share this post


Link to post
Share on other sites
:P ugh

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

UDPBind

UDPRecv

Edited by Paulie

Share this post


Link to post
Share on other sites

yes but you have to bind it to a port. The port that it needs to bound to....is the port that the data is sent on originally... but that port is randomly selected when you UDpOpen/UDpSend

Share this post


Link to post
Share on other sites

$g_IP="63.124.142.3"
$g_port=8001
UDPStartup()
dim $temp
$Socket=UdpOpen($g_IP,$g_port)
if @Error <> 0 Then 
Msgbox(0,"",@error)
Exit
EndIf
UDpSend($socket,"\status\")
UDPCloseSocket($socket)
$socket=UDpBind($g_IP,$g_port)

While 1
    $data = UDPRecv($socket, 256)
    If $data <> "" Then
        MsgBox(0, "UDP DATA", $data, 1)
    EndIf
    sleep(100)
Wend
Func OnAutoItExit()
    
    UDPCloseSocket($Socket)
    UDPShutdown()
EndFunc

Ethereal Shows:

No. Time Source Destination Protocol Info

26 1.087302 192.168.1.102 63.124.142.3 UDP Source port: 4325 Destination port: 8001

Frame 26 (50 bytes on wire, 50 bytes captured)

Ethernet II, Src: Dfi_f0:f9:f1 (00:01:29:f0:f9:f1), Dst: Cisco-Li_68:6a:02 (00:14:bf:68:6a:02)

Internet Protocol, Src: 192.168.1.102 (192.168.1.102), Dst: 63.124.142.3 (63.124.142.3)

User Datagram Protocol, Src Port: 4325 (4325), Dst Port: 8001 (8001)

Data (8 bytes)

0000 00 14 bf 68 6a 02 00 01 29 f0 f9 f1 08 00 45 00 ...hj...).....E.

0010 00 24 46 7d 00 00 80 11 64 be c0 a8 01 66 3f 7c .$F}....d....f?|

0020 8e 03 10 e5 1f 41 00 10 87 73 5c 73 74 61 74 75 .....A...s\statu

0030 73 5c

No. Time Source Destination Protocol Info

27 1.219764 63.124.142.3 192.168.1.102 UDP Source port: 8001 Destination port: 4325

Frame 27 (109 bytes on wire, 109 bytes captured)

Ethernet II, Src: Cisco-Li_68:6a:02 (00:14:bf:68:6a:02), Dst: Dfi_f0:f9:f1 (00:01:29:f0:f9:f1)

Internet Protocol, Src: 63.124.142.3 (63.124.142.3), Dst: 192.168.1.102 (192.168.1.102)

User Datagram Protocol, Src Port: 8001 (8001), Dst Port: 4325 (4325)

Data (67 bytes)

0000 00 01 29 f0 f9 f1 00 14 bf 68 6a 02 08 00 45 00 ..)......hj...E.

0010 00 5f 15 09 00 00 71 11 a4 f7 3f 7c 8e 03 c0 a8 ._....q...?|....

0020 01 66 1f 41 10 e5 00 4b 87 4e 5c 67 61 6d 65 6e .f.A...K.N\gamen

0030 61 6d 65 5c 75 6e 72 65 61 6c 5c 67 61 6d 65 76 ame\unreal\gamev

0040 65 72 5c 32 32 35 5c 6d 69 6e 67 61 6d 65 76 65 er\225\mingameve

0050 72 5c 32 32 34 5c 6c 6f 63 61 74 69 6f 6e 5c 30 r\224\location\0

0060 5c 71 75 65 72 79 69 64 5c 34 39 2e 31 \queryid\49.1

So everything is being sent/recived correctly, but my script isnt showing the recieved data

Share this post


Link to post
Share on other sites

Ok, problem solved. The problem was that i was trying to bind a new socket rather than using the one i Previosly sent data on... i was under the impression you had to use UDPBind with UdpRcv

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