Jump to content

UDPSend


Recommended Posts

I want to check if the message from UDPsend() arrived at the goal IPAddr.

The standard @error messages just tell me:

-1, -2 or -3 invalid socketarray.
1 - IPAddr is incorrect.
2 - port is incorrect.

But I want to know if the IPAddr was reachable.

I think _WinAPI_ could be usefull but I don't know what function I need.

Here a shortcut of my script:

#include <WinAPIDiag.au3>

; =================================================
; Topic.......: UDP StartUp :......................
Global $socketPort = 1927
UDPStartUp()
$udpSocket = UDPBind(@IPAddress1, $socketPort)
$starttime = TimerInit()
; =================================================

_UDP_Send_alive()

Func _UDP_Send_alive()
$socket = UDPOpen("10.46.229.220", 1927, 1)
$send = UDPSend($socket, "Test")
$error_classic = @error
$error_winAPI = _WinAPI_GetErrorMessage($send,)
ConsoleWrite($error_winAPI & @CRLF & $error_classic & @Crlf)
EndFunc
Link to comment
Share on other sites

As I understand it, the whole point of UDP is sending without verification and is not guaranteed to reach destination.

TCP is guaranteed.

UDPSend will return 0 if nothing is sent though.

Use Ping function to test if dest is reachable.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Hello JohnOne,

Thank your for your quick reply !

In the reference of UDPSend is mentioned "windows API WSAGetError return value (see MSDN)."

So I thought that on some way it is possible to get more error informations with _WinAPI_.

But if not then not...

Link to comment
Share on other sites

I'm not 100% certain UDPSend even uses sockets, a code dev would know better.

But if it were then I think as indicated in the link you provided, WSAGetLastError() might be the function to use.

I believe it resides in Ws2_32.dll.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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...