Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Using 'wait with a series of ports

From: seth::chromick::earthlink::net at: 14-Nov-2003 3:53

Thanks to all who answered my first question regarding the MUD I am coding! I have toyed around with this more and I am running into an issue. Code: server: open/lines tcp://:23 ; listen for connections clients: copy [] insert clients server Then obviously client/1 = server But if lower down I have... connection: wait/all clients How do I determine the position of the port in the 'clients series? Also, how do I determine if the port that is now active is a) a new connection or b) already a known connection, but is trying to send data to the server (like the user has typed something in, a name/password, etc.). Thanks for the help, I know I can depend on people here :] Here is the code I'm messing with (not functional from all the tweaking I've been doing!) --- REBOL [] print ["The MUD server has started on" now/date ", at" now/time] server: open/lines tcp://:23 ; listen for connections clients: copy [] y: copy [] insert clients server buffer: make string! 1024 forever [ ; Simple enough... Wait indefinitly for the first activity on the server port (23) ;connection: wait first server connection: wait/all clients ; Append the new connection to the list of clients append clients connection ; Inform the new connection that it is now properlly connected x: reform ["Now connected:" last client port-id] insert tail connection x print x ; Loop through each client to inform of a new join to the server foreach client clients [ either equal? client connection [ x: "You are connected now!" ][ x: "Someone new has joined!" ] insert client x ] ]