[Gambas-user] How to free an object with an active ServerSocket?

T Lee Davidson t.lee.davidson at gmail.com
Tue Dec 8 00:21:32 CET 2020


I have a project using a class that implements a ServerSocket.
In Form_Close(), set the object variable to Null so the object's _free method will get called.
But, with a ServerSocket actively Listening in that object, the _free method does not get called.

Is this by design? Am I doing something wrong? What is the proper manner in which to free an object with an active server?

It is simple to reproduce with a simple empty form:
' Gambas class file
' FMain.class

Private MyTester As Tester

Public Sub Form_Open()
   MyTester = New Tester As "MyTester"
End

Public Sub Form_Close()
   MyTester = Null
End

' Gambas class file
' Tester.class

Private MyServerSocket As ServerSocket

Public Sub _new()
   MyServerSocket = New ServerSocket As "MyServerSocket"
   MyServerSocket.Type = Net.Internet
   MyServerSocket.Port = 9090
   ' MyServerSocket.Listen ' Uncomment to prevent _free from being called.
End

Public Sub _free()
   Print "FREE"
   MyServerSocket.Close
End


-- 
Lee


More information about the User mailing list