WIP on Sockets

Tony Garnock-Jones tonyg at lshift.net
Mon Nov 7 16:48:29 PST 2005


Patch attached.

Notes
=====

This is a large refactoring and reimplementation of the sockets binding.
I'm sure to have gotten a lot wrong, especially regarding
ExternalResource usage. Any comments or criticisms gratefully received!

Socket locators have been split into endpoints and locators: endpoints
describe an IP-address/port-number pair, more-or-less, and locators
contain an endpoint and some indication of whether it's a server-socket
or a client-socket. That way, when the image starts up, it can tell
whether to try to connect or try to listen. Comments on this approach,
please.

Ip4Address is its own thing, separate from endpoints and locations.

DNS is separate from the other socket code, as logically DNS is a
separate mapping from DNS-names to various RRs, including but not
limited to A records.

I've tried to leave an IPv6-shaped hole, but not having coded for IPv6
myself ever, chances are it'll be up to someone else to fill it and
refactor appropriately.

Regarding socket.c, the principle I'm following is do as little as
possible in each primitive - in particular, primitives do not loop
internally. This allows the slate code full control over control-flow
and process scheduling. Also, each primitive is expected to indicate
errno somehow. I've chosen a naive but effective encoding for errno.

All socket operations are nonblocking, for integration with a
select()-loop scheduler.

I've removed REUSE_PORT as it's a bad idea IIRC. (Also, I've never had a
use for it personally.) We can put it back if it's required. REUSE_ADDR
is very useful, so it's stayed.

Gross attempt at Net SocketLib ErrorCodes probably needs cleaning up
somehow. What's idiomatic here? Similarly for Net SocketLib Mixin. Part
of the problem there, though, is that ExternalResource needs
refactoring. (See BUGS.)

The #sessionDo: method on the mixin is complete rubbish, and needs to go
once ExternalResources are fixed.

Hooks into the Scheduler are stubbed out (see the "error: 'Argh'") but
not implemented. A blocking operation will probably loop, complaining
"Argh", until the waited-for event comes in.

I'd also like advice on the shapes the Multiplexor could take, please.

Cheers,
  Tony
-------------- next part --------------
A non-text attachment was scrubbed...
Name: half-socket-patch-20051107.gz
Type: application/x-gzip
Size: 12139 bytes
Desc: not available
Url : /archives/slate/attachments/20051108/55445587/half-socket-patch-20051107.bin


More information about the Slate mailing list