Page 1 of 1

UDP IP setup

Posted: Thursday 4th January 2024 1:45pm
by GrantXTV
Hi All,

I upgraded last night from Gambas 3.14.3 to 3.18.4 and found that the UDP receiver as part of gb.net is no longer working, here is the code in question:

Public Sub UDPUser_Read()

Dim $Data As String

Read #UDPUser, $Data, Lof(UDPUser)
$VidData = $Data
' Print $Data

End

With testing it with print, I could see that data was coming in with version 3.14.3 and on 3.18.4 there was nothing, has there been format change in how this works in the later version of Gambas?

Testing the send part still works well, but it seems that something is going on with the receiver side.

Re: UDP IP setup

Posted: Thursday 4th January 2024 4:05pm
by BruceSteers
I don't know of any change from 3.14 to now
It's hard to tell without seeing your code or a test app.

Does the UDPUser_Read() event trigger?

is the socket opened like this...

UDPUser = New UdpSocket As "UDPUser"

and opened in the same class as the UDPUser_Read() sub

Re: UDP IP setup

Posted: Thursday 4th January 2024 6:25pm
by GrantXTV
Hi Bruce,

"Does the UDPUser_Read() event trigger?" yes
I am getting date come out now, the issue seem to be also with the String processing for example at the next step:

$TXDataRY = Left$($VidData, 2880)
$TXDataBY = Mid$($VidData, 2881, 2880)
'$TXDataBY = Mid$("test test", 6, 4)

Print "-" & $TXDataBY & "+"

If I print out "$TXDataBY = Mid$($VidData, 2881, 2880) " I get nothing between the "-+", but if do the same with "$TXDataBY = Mid$("test test", 6, 4)" I get "-test+" printed out. Left$ and Mid$ seem to have issues with larger numbers, in the later version.

I am sending video information between two computers with UDP and therefore I getting very large strings to work with.

Any ideas?
Other Topic.

Re: UDP IP setup

Posted: Thursday 4th January 2024 6:47pm
by BruceSteers
only that the strings could be being sent in part over multiple Read events.

have you checked $VidData.Len > 2880

Or should that be String.Len($VidData) as with non-UTF8 strings like image data it will make a difference

Re: UDP IP setup

Posted: Thursday 4th January 2024 9:43pm
by GrantXTV
Print String.Len($VidData)

I get 18152 more than I require to work with using ascii 8bit, no issues on the older version with the same code.

Re: UDP IP setup

Posted: Thursday 4th January 2024 9:58pm
by thatbruce
Just as a test, try chopping the data instead of using mid

Dim tmp as String
$TXDataRY = Left$($VidData, 2880)
tmp = Left$($VidData,-2880)
$TXDataBY=Left$(tmp,2880)

Print "-" & $TXDataBY & "+"

b

Re: UDP IP setup

Posted: Friday 5th January 2024 2:25pm
by GrantXTV
Yes, tried this code out and got the same output:
-+

Years working with strings and they seem simple, but from this test Left$ and Mid$ have the same issue.