Jump to content
Sign in to follow this  
livewire

TCP/UDP Binary?

Recommended Posts

livewire

Is it possible to receive Binary data in AutoIt from a program other than AutoIt (for example...a C++ program that sends out one float)?

I'm using beta version 3.2.3.14. My C++ program continuously sends out one float and I would like to display this number in AutoIt. Is this possible solely through AutoIt code?

My code below does nothing when the UDP data of the float is received.

#include <GUIConstants.au3>
     
     UDPStartup()
     
     $socket = UDPBind("127.0.0.1", 3333)
     If @error <> 0 Then
         MsgBox(0,"Testing","Error binding...")
         Exit
     EndIf
     
     #Region ### START Koda GUI section ### Form=
     $Form1 = GUICreate("Server", 338, 249, 193, 114)
     $Label1 = GUICtrlCreateLabel("", 72, 72, 400, 17)
     GUISetState(@SW_SHOW)
     #EndRegion ### END Koda GUI section ###
     
     While 1
         $nMsg = GUIGetMsg()
         Switch $nMsg
             Case $GUI_EVENT_CLOSE
                 Exit
         EndSwitch
         
         $data = UDPRecv($socket, 50)
         If $data <> "" Then
             If IsBinary($data) Then
                 GUICtrlSetData($Label1,"Binary: " & String($data))
             Else
                 GUICtrlSetData($Label1,"String: " & $data)
             EndIf
         EndIf
     WEnd
     
     Func OnAutoItExit()
         UDPCloseSocket($socket)
         UDPShutdown()
     EndFunc

Thanks,

Livewire

Edited by livewire

Share this post


Link to post
Share on other sites
livewire

Nevermind...it works...it was my problem. What I was receiving was bigger than 50 bytes.

$data = UDPRecv($socket, 50)

-Livewire

Edited by livewire

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  

×