Test app UDPSocket Broadcast

Post

Posted
Rating:
#1 (In Topic #1030)
Trainee
 Here is my first test app.

Trying to broadcast udp packets.

few questions.

1. From what I can tell once I create an object I cannot destroy it (vb6 set object = nothing)?

2. I could not find an example of udpsocket, so I took hints from socket example, please be gentle it is my first try

3. What is the easiest way to get localIP of machine

to clarify the udpsock status returns 1 but i cannot see any packets being sent on my network

thank you

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’

axisdj said

1. From what I can tell once I create an object I cannot destroy it (vb6 set object = nothing)?
In Gambas some Objects, especially graphic ones, possess the ".Delete()" Method in order to be destroyed.
In order to destroy, however, those Objects which do not have the .Delete() Method, it is sufficient to assign the value <COLOR color="#BF0000">Null</COLOR> to the variable of the specific Object type.

Code (gambas)

  1. object_variable = Null

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
 Ok thanks, I tried that and the class that had the timer and udpsocket was not getting destroyed and the _free event was not occuring

Any help on why my test app is not broadcasting the data, would be greatly appreciated when you have time
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
vuott is in the usergroup ‘Regular’
Sorry, I didn't understand.  :|
My suggestion doesn't work?

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
vuott is in the usergroup ‘Regular’

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#6
Trainee

vuott said

Sorry, I didn't understand.  :|
My suggestion doesn't work?

when I set the instance of the class = nothing it did not destroy instance, and the _free event did not occur

so it was continuing to attempt to send udp packets

I worked around it …

Please see the project attached and let me know if I am using UDPsocket correctly for broadcasting
Online now: No Back to the top

Post

Posted
Rating:
#7
Online now: No Back to the top

Post

Posted
Rating:
#8
Guru
BruceSteers is in the usergroup ‘Guru’

axisdj said

vuott said

Sorry, I didn't understand.  :|
My suggestion doesn't work?

when I set the instance of the class = nothing it did not destroy instance, and the _free event did not occur

so it was continuing to attempt to send udp packets

I worked around it …

Please see the project attached and let me know if I am using UDPsocket correctly for broadcasting

the attached project contains no source code.
How did you pack it?
It's best to make an archive using the IDE , select "Project/Make source archive" this will include what is needed and omit what's not needed.

and you should not set "class" = nothing you should set "object" = nothing.
Do you understand the difference?  you create an object from the class like this..
Dim hObject = New UDPSocket

then you must do
hObject = Null

not UDPSocket = Null
Online now: No Back to the top

Post

Posted
Rating:
#9
Guru
BruceSteers is in the usergroup ‘Guru’
Are you closing the socket first?
/comp/gb/stream/close - Gambas Documentation
Online now: No Back to the top

Post

Posted
Rating:
#10
Regular
vuott is in the usergroup ‘Regular’

BruceSteers said

and you should not set "class" = nothing you should set "object" = nothing.
Do you understand the difference?  you create an object from the class like this..
Dim hObject = New UDPSocket

then you must do
hObject = Null

not UDPSocket = Null
Infact.    <EMOJI seq="1f44d" tseq="1f44d">👍</EMOJI>
BruceSteers offers you an important clarification.

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#11
Trainee

BruceSteers said

axisdj said

vuott said

Sorry, I didn't understand.  :|
My suggestion doesn't work?

when I set the instance of the class = nothing it did not destroy instance, and the _free event did not occur

so it was continuing to attempt to send udp packets

I worked around it …

Please see the project attached and let me know if I am using UDPsocket correctly for broadcasting

the attached project contains no source code.
How did you pack it?
It's best to make an archive using the IDE , select "Project/Make source archive" this will include what is needed and omit what's not needed.

and you should not set "class" = nothing you should set "object" = nothing.
Do you understand the difference?  you create an object from the class like this..
Dim hObject = New UDPSocket

then you must do
hObject = Null

not UDPSocket = Null

yes I set the instantiated object = null and I called close on object. Problem is the _free event never occurred

I just noticed that option late yesterday.. here it is attached

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#12
Regular
vuott is in the usergroup ‘Regular’
I noticed that, if "Timer" and the variable "ws" are both active, they will not allow the hidden Method "_free()" to be raised.

I :? would make these changes:

1)

Code (gambas)

  1. Public Sub SwitchButton1_Click()
  2.   If SwitchButton1.Value = False Then
  3.     art.Delete()
  4.     Me.Caption = "UDP Socket Off"
  5.   Else  
  6.   ...etc...etc...
.

2) In "clsArtNet" I'ld add this sub-procedure:

Code (gambas)

  1. Public Procedure Delete()
  2.  
  3.   myTimer.Stop
  4.   ws.Close
  5.   ws = Null
  6.  

3) In "clsArtNet" I'ld erase the whole SUB: "Public Sub _free() ".

<COLOR color="#FFFFFF">.</COLOR>

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#13
Trainee

vuott said

I noticed that, if "Timer" and the variable "ws" are both active, they will not allow the hidden Method "_free()" to be raised.

I :? would make these changes:

1)

Code (gambas)

  1. Public Sub SwitchButton1_Click()
  2.   If SwitchButton1.Value = False Then
  3.     art.Delete()
  4.     Me.Caption = "UDP Socket Off"
  5.   Else  
  6.   ...etc...etc...
.

2) In "clsArtNet" I'ld add this sub-procedure:

Code (gambas)

  1. Public Procedure Delete()
  2.  
  3.   myTimer.Stop
  4.   ws.Close
  5.   ws = Null
  6.  

3) In "clsArtNet" I'ld erase the whole SUB: "Public Sub _free() ".

<COLOR color="#FFFFFF">.</COLOR>

Thank you and I do understand, but my MAIN question is am I using the udpSocket correctly for broadcasting data. I cannot see the packets on my network.
Online now: No Back to the top

Post

Posted
Rating:
#14
Regular
vuott is in the usergroup ‘Regular’
Hello,
I currently have no experience with this Class.
I :? don't know if this page can help you:
UDP-Socket - Der Gambas Club

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#15
Trainee
 Hello Everyone.

I was able to make it work, the biggest obstacle was the fact that the linux sbc network card had a special setting that needed to be set (detect method I think)

My code did not follow the udpSocket example in the Gambas book, but I got it working so I am well on my way.
Online now: No Back to the top
1 guest and 0 members have just viewed this.