NilObjectException on button with serversocket.listen

Hello

I want to create an application that listens for incoming TCP connections. (And connects to a database.)
I made a simple form, with a button on it (the start button). Code is:

[code] MyServerSocket.Listen

db = New MySQLCommunityServer
db.Host = “192.168.2.156”
db.Port = 3306
db.DatabaseName = “concerto_production”
db.UserName = “xxx”
db.Password = “xxx”[/code]

When I press the button in debug mode, the form just dissapears. When I append a Msgbox after the database connection, I get a NilObjectException. When I delete the ‘MyServerSocket.Listen’, all behaviour is normal.

What am I doing wrong with the MyServerSocket.Listen?

Thanks

Have you created an instance of MyServerSocket? As in MyServerSocket = New ServerSocket with appropriate settings (port, MaximumSocketsConnected, MinimumSockets)? A ServerSocket has some default values that don’t work in a live environment i.e. you can 't connect to it, so have a look at the documentation.

I should’ve mentioned this: MyServerSocket is a socket that is dropped on the form (thus instanciated) with the right settings set.

Is the socket a ServerSocket? If so have you added the event handler for AddSocket and returned a TCPSocket subclass?

From my experience the ServerSocket class will attempt to create minimum sockets + 10 (up to maximum sockets) objects when you call the Listen method, if you haven’t returned a socket you’ll get the results you’re seeing.