Re: Networking with CL
- From: Russell McManus <russell_mcmanus@xxxxxxxxx>
- Date: Sun, 10 Feb 2008 14:45:57 -0600
"Alex Mizrahi" <udodenko@xxxxxxxxxxxxxxxxxxxxx> writes:
yes, i think so. as you see, abstraction that is good for TCP
(streams) is not good even for it's socket brother UDP. what's
about other network protocols and architectures?
Streams are actually a lousy abstraction for reading from a network
socket. The abstraction does work cleanly for writing, however.
When reading, you really want to say to the system "please start
reading data from this socket until a fully formed data blob has been
read, and then call this function with the blob."
Of course the meaning of "fully formed data blob" is dependent on the
protocol you're reading. For HTTP it's \r\n\r\n or something like
that. You might have a fixed length message coming at you. Or one
can imagine a header/body protocol with a fixed length header telling
you how many bytes are in the body. Etc.
You can do all of this with a stream interface, except then you're
forced to use threads, because for many protocols you don't know how
much data you need to read, so you have to block[1]. I find debugging
threaded programs much more difficult than non-threaded programs, so I
think this is a serious disadvantage for using streams to read from
sockets.
Also, one thread per client has kind of sucky resource requirements,
compared to just using poll / kqueue / epoll / IOCP or what have you.
I mention all of the above, because I'm just finishing up an interface
to the poll(2) system call for sbcl. Let me know if you want to see
it...
also note that different people want to work with networking at
different abstraction level: some people are satisfied with streams,
other people would like to modify IP headers on packet level.
Or maybe threads are just too hard, let's go shopping...
and all this stuff is highly system-dependent.. event
demultiplexing, for example. should they make all networking doomed
to be synchonous, or require implementors to implement ``select'' on
systems which do not support it?
Keep in mind that this type of IO is only available on MacOS, BSD,
Linux, Solaris, AIX, and Windows. Oh wait, I'm probably forgetting a
few.
-russ
[1] I'm aware of CMUCL's recursive event loop that hides the blocking.
It's a nice hack, but IMHO it's a heroic attempt to pound a square peg
into a round hole.
.
- Follow-Ups:
- Re: Networking with CL
- From: Alex Mizrahi
- Re: Networking with CL
- References:
- Networking with CL
- From: nicolas . edel
- Re: Networking with CL
- From: Alex Mizrahi
- Re: Networking with CL
- From: nicolas . edel
- Re: Networking with CL
- From: Alex Mizrahi
- Networking with CL
- Prev by Date: Re: Paul Graham's Arc is released today... what is the long term impact?
- Next by Date: Noob Question: Can somebody explain to me what @ does in front of a loop
- Previous by thread: Re: Networking with CL
- Next by thread: Re: Networking with CL
- Index(es):
Relevant Pages
|