[Gambas-user] Writing classes to handle incoming socket connections with ServerSocket
Ronan Chilvers
ronan at ...384...
Mon Apr 5 22:18:46 CEST 2004
Hi folks
I'm really interested in using Gambas to do some socket programming. I want to write a 'dispatcher' class holding the ServerSocket, which hands off the incoming connections to a 'clienthandler' class to handle that particular connection.
The problem is I can't work out how to pass the sockets around between the classes. This is the kind of thing I'm doing:-
Dispatcher.class
PRIVATE dSocket as ServerSocket
PUBLIC SUB _new(port)
dSocket = new ServerSocket as "dSocket"
END
PRIVATE SUB dSocket_Connection(dHost as String)
DIM obj as ClientHandler
obj = new ClientHandler(dSocket.Accept())
END
ClientHandler.class
PRIVATE cSocket as Socket
PUBLIC SUB _new(sock as Socket)
cSocket = sock
END
PRIVATE SUB cSocket_Read()
'Read data from socket and do stuff with it
'***** This never executes *****
END
That's the basic idea. However when I connect to the listening port, the connection immediately drops and the _Read event never fires. The ClientHandler object is created fine and the child socket is passed through fine, as I can read parameters such as RemoteHost from the cSocket property of the new ClientHandler object.
Any clues would be very much appreciated ! :-)
Cheers
Ronan
--
e: ronan at ...384...
t: 01903 739 997
w: www.thelittledot.com
TheLittleDot is a partnership of
Ronan Chilvers and Giles Webberley
This message has been digitally signed
to verify sender identity
( GNUPG 1.2.4 : http://www.gnupg.org )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20040405/d88e112c/attachment.sig>
More information about the User
mailing list