Parrot Socket I/O - request for help

Mark Glines mark at glines.org
Fri Mar 27 16:01:24 UTC 2009


Allison Randal wrote:
> So, methods or vtable functions for those behaviors need to be added.
> 
> In the pdd, the Socket PMC has a 'socket' method (essentially parallel
> to the 'open' method on the FileHandle PMC). You should be able to
> create a Socket PMC with the standard 'new':
> 
>   $P0 = new 'Socket'
>   $P1 = new 'Socket', init_hash

And $P0."socket"(2, 1, 6) # still need to define some constants

So I'm working on adding an init_pmc vtable and a socket method, the
former calls the latter.  One problem I've run into is that the PIO
routines expect to allocate the PMC, whereas the above API implies the
PMC should allocate the underlying PIO socket as needed.  Are we somehow
married to the current design, or is it ok if I switch them around?
(The above API to me looks like Parrot_io_socket() should be called by
the Socket PMC, and should return an integer.)

The attached patch implements this for the Socket PMC (I haven't done
SockAddr yet), and the updated httpd example works correctly under
linux.  I haven't tested it on win32 yet, and I don't know how sockets
are supposed to work on PIO_OS_STDIO platforms.  But is this a valid
approach?

Mark

P.S.  I also noticed in Parrot_io_socket_win32 and Parrot_io_socket_unix
 that the setsockopt for SO_REUSEADDR was called with an uninitialized
integer, I fixed that too.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: stop-using-socket-opcode.patch
URL: <http://lists.parrot.org/pipermail/parrot-dev/attachments/20090327/18f5e31b/attachment.diff>


More information about the parrot-dev mailing list