Jump to content
Sign in to follow this  
funkey

UDPRecv bug?

Recommended Posts

funkey

Hello,

I just want to know if this is a bug?

 
Global $Info = _GetServerInfo()
If @error Then
 ConsoleWrite("Error " & @error & " getting info" & @CRLF)
Else
 ConsoleWrite($Info & @CRLF)
EndIf
Func _GetServerInfo()
 UDPStartup()
 Local $socket = UDPOpen("192.168.5.5", 20500)
 If @error <> 0 Then Return SetError(1, 0, "")
 UDPSend($socket, "GetServerInfo" & Chr(0))
 If @error <> 0 Then Return SetError(2, 0, "")
 Local $data = UDPRecv($socket, 50, 2) ; if UDP-server is not reachable, then no error is set and no array is created
 If @error <> 0 Then Return SetError(3, 0, "")
 UDPCloseSocket($socket)
 UDPShutdown()
 Return $data[0]
EndFunc   ;==>_GetServerInfo

 

If server IP is local IP then an error is thrown as expected.


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites
FireFox

Hi,

If the server is reachable you mean?

I have the same issue, it returns an empty string with the flag set to 2.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
funkey

So should I open a ticket in Bugtracker?


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites
Jos

It looks like the @Error isn't set in case the FD_ISSET call fails, meaning the UDP socket isn't ready, so guess this is indeed an bug that needs to be looked at.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
funkey

Thanks, Jon!


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites
FrankwazHere
Hi Guys,
 
Since the version 10, this TCPRecv change has broken my script... if I compile the script with version 8 the connection is stable and doesn't throw any @error
 
While 1
  $recv = TCPRecv($Socket, 1024)
    If @error Then
      Connect()
    EndIf

now when i compile the same script with version 10 it just connects, @error's - disconnects, then connects again, @errors - disconnects, in a loop.

I viewed the @error with a messagebox it returned -1, why would this work on the old 8 but not on the new 10 version. is it one of those, Fix one thing, break another scenario?

Thanks;

Edited by FrankwazHere

;Frank. 

Share this post


Link to post
Share on other sites
Graeme

I have a small script:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****


If Not UDPStartup() Then
    MsgBox (0,"UDPStartup",@error & "TunnelDisabledActionString")
Else
    $UDPLogPort = Random(20000,65535,1)
    $UDPLogReceiver = UDPBind("127.0.0.1",$UDPLogPort)
    If (@error > 0) Then
        $UDPLogPort = Random(20000,65535,1)
        $UDPLogReceiver = UDPBind("127.0.0.1",$UDPLogPort)
        If (@error > 0) Then
            MsgBox (0,"UDPBind",@error&"TunnelDisabledActionString")
            $UDPLogReceiver[0] = 0
        EndIf
    Else
            MsgBox(0,"UDPBind","Realsocket=" & $UDPLogReceiver[1] & " IP=" & $UDPLogReceiver[2]&" port= "& $UDPLogReceiver[3])
    EndIf
EndIf
For $I = 1 to 1
    If $UDPLogReceiver[0] <> 0 Then
        $received = UDPRecv($UDPLogReceiver,16000)
        If @error And (@error <> 10040) Then
            MsgBox(0,"UDPRecv",@error)
        Else
            MsgBox(0,"UDPRecv",$I&" "&$received)
        EndIf
    EndIf
    Sleep(100)
Next

and it gives different results run under 3.3.8.1 and 3.3.10.2 as attached

Is this a bug that still exists? Sorry if this is the wrong place for the question but I thought it would be good to continue the thread.

So basically the error results in 3.3.10.2 but not in 3.3.8.1 it shows $I instead.

post-84035-0-34642300-1395322872_thumb.p

Edited by Graeme

Share this post


Link to post
Share on other sites
jpm

In fact the Jos remark is still valid the socket is not ready.

The only think you can contest is that -1 in the doc means invalid socket array which is not the reality

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  

×