UDP IP setup

Post your Gambas programming questions here.
Post Reply
GrantXTV
Posts: 17
Joined: Tuesday 31st October 2023 9:20pm

UDP IP setup

Post 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.
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: UDP IP setup

Post 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
If at first you don't succeed , try doing something differently.
BruceS
GrantXTV
Posts: 17
Joined: Tuesday 31st October 2023 9:20pm

Re: UDP IP setup

Post 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.
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: UDP IP setup

Post 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
If at first you don't succeed , try doing something differently.
BruceS
GrantXTV
Posts: 17
Joined: Tuesday 31st October 2023 9:20pm

Re: UDP IP setup

Post 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.
User avatar
thatbruce
Posts: 168
Joined: Saturday 4th September 2021 11:29pm

Re: UDP IP setup

Post 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
Have you ever noticed that software is never advertised using the adjective "spreadable".
GrantXTV
Posts: 17
Joined: Tuesday 31st October 2023 9:20pm

Re: UDP IP setup

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