Commit Graph
6 Commits
Author SHA1 Message Date
Fabian Fett 7c92a3e4d8 NIOUDPServer use AddressedEnvelope as InboundIn and OutboundOut (#1666) 2020-10-02 17:08:54 +01:00
Cory Benfield 30265d69a8 Adjust names of BSDSocket option values. (#1510)
Motivation:

The names of most of the BSD socket option values were brought over into
their NIO helper properties, with their namespace removed. This vastly
increases the risk of collision, particularly for things like TCP_INFO,
which just became .info.

Modifications:

- Added the prefixes back, e.g. `.info` is now `.tcp_info`.
- Renamed socket type `.dgram` to `.datagram`, as this is the nice clean
  API and we should use nice clean names.

Result:

Better APIs
2020-05-11 15:13:58 +01:00
Saleem AbdulrasoolandCory Benfield bcc180dab6 Add new BSDSocket namespace (#1461)
* NIO: Add new `BSDSocket` namespace

This starts the split of the POSIX/Linux/Darwin/BSD interfaces and the
BSD Socket interfaces in order to support Windows.  The constants on
Windows are not part of the C standard library and need to be explicitly
prefixed.  Use the import by name to avoid the `#if` conditions on the
wrapped versions.  This will allow us to cleanly cleave the dependency
on the underlying C library.

This change adds a `BSDSocket.OptionLevel` and `BSDSocket.Option` types
which allow us to get proper enumerations for these values and pipe them
throughout the NIO codebase.

* Apply suggestions from code review

Co-Authored-By: Cory Benfield <lukasa@apple.com>
2020-04-02 19:06:48 +01:00
Liam Flynn df4e078c74 Add 2 missing server readme docs. (#940)
Add missing server readme docs for WebSocket server and UDP echo server.

Motivation:
With the exception of these two samples, all client and server examples have helpful readme docs.
Provides brief description of purpose of the sample code and how to run it.

Modifications:
Adds a readme to NIOUDPEchoServer.
Adds a readme to NIOWebSocketServer.

Result:
The samples for NIOUDPEchoServer and NIOWebSocketServer have a little explanation.
2019-04-02 11:28:31 +01:00
Johannes Weiss f1efb4a104 new http parser (#814)
Motivation:

The old HTTP parser tried to convert `http_parser` to a one-shot parser
by pausing it constantly. That was done to be resilient against
re-entrancy. But now, we have the new `ByteToMessageDecoder` which
protects against that so HTTP decoder can just become a real
`ByteToMessageDecoder`. It also serves as a great testbed for
`ByteToMessageDecoder`.

Modifications:

- make the HTTP decoder a `ByteToMessageDecoder`
- refactor the implementation

Result:

cleaner code, more use of `ByteToMessageDecoder`
2019-03-06 11:51:42 +00:00
Cory Benfield b13bc66062 Support using recvmmsg to perform gathering reads. (#743)
Motivation:

Some DatagramChannels are extremely high-throughput. This can occur
when UDP is being used as an encapsulation for a transport protocol
(e.g. QUIC), or when a highly utilized service is being offered on a
single port (e.g. DNS).

In these cases, the syscall overhead of datagram reads is quite high
(one recvfrom call per datagram). It would be helpful to be able to
trade off some memory usage in order to reduce the cost of the syscalls
in this situation.

This patch adds support for transparently using the recvmmsg syscall
to achieve this kind of tradeoff.

Modifications:

- Added support to the DatagramChannel for issuing vector reads.
- Added new ChannelOption: DatagramVectorReadMessageCountOption
- Added UDP echo server example to exercise functionality.
- Tests

Result:

Able to achieve higher read throughput on supported systems.
2019-03-05 11:25:21 +00:00