From: jsc@atype.COM (Jin S. Choi)
Date: 18 Jun 1996 11:27:16 -0400
I'm interested in writing a multiuser game server using scsh, one
where clients can connect, log in, and interact with other
This requires non-blocking sockets, so that the server can
process current clients while accepting new ones. As scsh doesn't
currently support threads, the only way I've found to be able to do
this is to use a big event loop, selecting on all the user sockets and
the accept socket. Unfortunately, the scsh select function doesn't
seem to want to take any sockets I feed to it, claiming it's a bad
argument; it only likes small integers and fdports. The man page for
It is possible to select(2) a socket for the purposes of
doing an accept by selecting it for read.
so I was wondering if it would be possible to allow sockets to get
through select's type checking.
A C socket (which is what the select(2) man page describes) is an integer
file descriptor. You can feed it to the C select function.
A scsh socket is a more complex record, with the following structure:
family ; protocol family
inport ; input port
outport ; output port
You can't feed one of these things to the scsh SELECT procedure -- SELECT only
takes integer file descriptors and Scheme I/O ports.
But you *can* feed the ports (SOCKET:INPORT sock) and (SOCKET:OUTPORT sock)
to SELECT -- they *are* ports.
We would have avoided this small complication by representing a socket in scsh
as a bidirectional input/output Scheme port. But Scheme doesn't provide
bidirectional ports, so that's not possible. Instead, sockets package up a
pair of ports, one for each direction.
Does this answer your question? You can find more detail in the sockets
chapter of the manual.
P.S. One more hint: if you want to do a multi-player game with sockets,
you might talk to Prof. Ian Horswill (firstname.lastname@example.org). He has
students who work on similar stuff in S48, too.