Grant Proposal: Improve Perl 6 Networking Support

7 Comments

The Grants Committee has received the following grant proposal for the Nov/Dec round. Before the Committee members vote, we would like to solicit feedback from the Perl community on the proposal.

Review the proposal below and please comment here by December 22nd, 2018. The Committee members will start the voting process following that.

Improve Perl 6 Networking Support

  • Name:

    Ben Davies

  • Amount Requested:

    USD $7200

Synopsis

Perl 6 lacks many features when it comes to networking in comparison to other languages. The aim of this is to give Perl 6 networking support equivalent to that of other languages, such as Python.

Benefits to the Perl Community

This will allow users to do more advanced networking without having to depend on NativeCall and will make the API for IO::Socket::Async and IO::Socket::INET more consistent. IO::Socket::UNIX will also be introduced to provide support for IPC with UNIX sockets.

Some of the reasons I am proposing this are that:

- SO_OOBINLINE is required for TELNET protocol

- Even after adding support for getsockopt/setsockopt, there's no way to use options that need to be set before connect/bind is called on both synchronous and asynchronous sockets, like SO_REUSEADDR

- Raw sockets are currently unusable without using NativeCall. This makes it impossible to write anything that depends on raw sockets, like ICMP, purely in Perl 6

- IPC is possible to do with TCP/UDP sockets, but UNIX sockets would allow users to share file descriptors between processes and would bypass the networking stack for faster IPC

Deliverables

This grant will allow Perl 6 to support:

- getting the file descriptors of IO::Socket::Async instances

- setsockopt/getsockopt on networking sockets

- setting options on IO::Socket::INET and IO::Socket::Async instances before bind/connect is called

- creating raw and UDP IO::Socket::INET sockets across all OSes

- sending/receiving data over raw and UDP IO::Socket::INET sockets

- creating UNIX sockets and being able to send and receive data, get/set options, etc. over them

Some of these features are breaking changes and will need to wait until 6.e.

Project Details

I have already started working on implementing .native-descriptor for IO::Socket::Async and getsockopt/setsockopt support.

Inch-stones

- Implement .native-descriptor for getting the file descriptors of IO::Socket::Async sockets

- Implement getsockopts op to get getsockopt/setsockopt option constants

- Implement getsockopt/setsockopt ops

- Implement asyncsocket op

- Refactor IO::Socket::Async to use nqp::asyncsocket

- Add a .new method to IO::Socket::Async

- Refactor IO::Socket::INET to allow creating sockets without having bind/connect called immediately

- Refactor IO::Socket::Async's UDP methods to allow using getsockopt/setsockopt on UDP sockets before they are bound

- Make initializing raw and UDP IO::Socket::INET sockets work across all OSes

- Implement sendto/recvfrom ops

- Implement unixsocket, unixopen, unixlisten, unixconnect ops

- Create IO::Socket::UNIX

- Implement unixsendfd/unixreadfd ops and support sending/receiving file descriptors over unix sockets

Project Schedule

I imagine this would take a few months to complete. I've already begun work on implementing .native-descriptor and getsockopt/setsockopt support, so I'm ready to start as soon as possible. I will be working around 6 hours a day on this.

3 months * 4 weeks * 5 days * 6 hours * $20 = $7200

Completeness Criteria

Whenever my code gets merged into MoarVM/nqp/rakudo's master branch.

Bio

I am a 22 year old self-taught programmer with 6 years experience. I know C, Perl 6, node.js, as well as some Python, Java, Rust, and Go. I've been working with networking-related code for around 5 years, particularly with TELNET and WebSockets. I've been contributing to Perl 6 core since December 2017 and have already made some changes to its networking features, like .native-descriptor for IO::Socket::INET.

7 Comments

I support this. Ben Davies has been working for a long time in Perl 6, released several modules, and what he aims for is something that is really needed in the Perl 6 ecosystem. +1 for this.

I can't comment on whether or not on the schedule, but I can say that this is one of my biggest disappointments in Perl 6 - things that were straightforward to do with networking in Perl 5 are definitely not in Perl 6. As an example, I'm implementing a BGP module in Perl 6 - but can't easily (portable, without NativeCall) set the TCP option for MD5 signatures (that may never be completely portable, but there aren't even good hooks to tie into the socket with today).

I've ended up writing my own socket code, mostly using NativeCall, to get around these problems. But it's fragile, non-portable, and definitely shouldn't be one of the better of the more ways to do it.

So with that in mind, I definitely support this effort!

+1, I'm excited. Raku indeed lacks many networking features, I'm happy that someone knowledgeable will be working on it.

Hello,

Would it perhaps become possible to support UNIX domain sockets as well? That would be great!

Thanks!

Regards,

Raymond.

Oops,

Never mind my previous comment...

...I was not reading properly. My apologies!

More complete control over network options and unix domain socket support would be very useful to have, I expect. +1

Yes PLEASE!
I wanted to port the ping monitoring part of our Perl 5 NMS to Perl 6 when we had to add IPv6 support but it wasn't possible due to missing raw sockets.

Leave a comment

About TPF

The Perl Foundation - supporting the Perl community since 2000. Find out more at www.perlfoundation.org.

About this Entry

This page contains a single entry by Coke published on December 16, 2018 5:14 PM.

Maintaining Perl 5 (Tony Cook): November 2018 Grant Report was the previous entry in this blog.

Grant Proposals Nov/Dec 2018 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 6.2.2