[Gambas-user] Network Programming
dovey.john at gmail.com
Tue May 18 09:03:25 CEST 2021
This is fantastic. If you don’t mind, I’ll take this and work on it a bit
more and maybe write up that chat server how to.
All the best
On Mon, May 17, 2021 at 5:49 PM T Lee Davidson <t.lee.davidson at gmail.com>
> On 5/17/21 3:19 PM, John Dovey wrote:
> > Does anyone know what happened to this page?
> > http://gambaswiki.org/wiki/tutorial/chat <
> > It seems to be exactly what I needed as a sample for something else I
> want to do.
> > Thanks
> > John
> I never even knew that page was there, lol. Anyway, there is example code
> at http://gambaswiki.org/wiki/doc/network#t13 that
> could likely be used as a basis for your needs. I took that code and
> reworked it a bit to make a simple chat server. I have not
> tested it so it may have (read, probably has) bugs.
> ' Gambas class file
> PUBLIC Clients AS Object
> PUBLIC Srv AS ServerSocket
> PUBLIC SUB FMain_Open()
> Clients = NEW Object
> Srv = NEW ServerSocket AS "Srv"
> Srv.Type = Net.Internet
> PUBLIC SUB Srv_Connection(Host AS String)
> PRINT "Accepting connection from --> " & Host
> PUBLIC SUB Socket_Read()
> DIM sCad AS String
> READ #LAST, sCad, Lof(LAST)
> FOR EACH oSocket as Socket in Clients
> IF oSocket.RemoteHost = LAST.RemoteHost THEN ' Don't echo to sender
> END IF
> WRITE #oSocket, sCad, Len(sCad)
> PUBLIC SUB Socket_Closed()
> PRINT "Connection closed"
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
Sent from Gmail Mobile
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the User