I have this code, where I listen using one socket and send a packet using another one, both in same program.
Receive doesn't seem to work, I checked with Wireshark that send happens.
Am I missing something?
#include <AutoItConstants.au3>
#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
; Create GUI
Local $w = 400
Local $h = 200
Local $b = 3
GUICreate("Local Discovery", $w, $h)
Local $idListView = GUICtrlCreateListView("UUID|IP|", $b, $b, $w - 2 * $b, $h - 2 * $b)
;GUICtrlSetTip(-1, '#Region LIST VIEW')
; Start the UDP service.
UDPStartup()
OnAutoItExitRegister("OnAutoItExit")
; Start listener
Local $msg = ""
Local $recv = UDPBind("239.255.250.250", 9130)
; Query widgets
Local $send = UDPOpen("239.255.250.250", 9130, $UDP_OPEN_BROADCAST )
UDPSend($send, "Hello")
UDPCloseSocket($send)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEButton")
GUISetState(@SW_SHOW)
While 1
$msg = UDPRecv($recv, 512)
If $msg <> "" Then
ConsoleWrite($msg)
GUICtrlCreateListViewItem("A|One", $idListView)
EndIf
Sleep(100)
WEnd
Func CLOSEButton()
Exit
EndFunc
Func OnAutoItExit()
; Close the UDP service.
UDPShutdown()
EndFunc