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

Using 'wait with a series of ports

 [1/3] 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 ] ]

 [2/3] from: antonr:iinet:au at: 14-Nov-2003 20:23


> server: open/lines tcp://:23 ; listen for connections > clients: copy []
<<quoted lines omitted: 3>>
> connection: wait/all clients > How do I determine the position of the port in the 'clients series?
Just use find like any other series. index? find clients connection
> 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 :]
Too hot to answer this. Anton.

 [3/3] from: maarten:vrijheid at: 14-Nov-2003 10:40


Hi
> Code: > server: open/lines tcp://:23 ; listen for connections
<<quoted lines omitted: 3>>
> But if lower down I have... > connection: wait/all clients
either server = connection [ it 's the server that has a new client ready, do a first server etc] [ if not it is a client ] I think this was in my original sample script as well I replied earlier? You can also do: Clients/1 = connection Or if you really wnat to complicate things: Not 1 = index? Find clients connection --Maarten

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted