0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-06 13:58:56 +01:00
construct/include/ircd/net
2018-01-11 22:02:33 -08:00
..
asio.h ircd: Fwd declare boost::system::error_code; minor cleanup. 2018-01-08 03:08:59 -08:00
close.h ircd::net: Rename sockopts to sock_opts. 2018-01-07 02:02:41 -08:00
hostport.h ircd::net: Improve remote construction; hostport/ipport related. 2018-01-10 01:20:16 -08:00
ipport.h ircd::net: Improve remote construction; hostport/ipport related. 2018-01-10 01:20:16 -08:00
listener.h ircd::net: listener: Explicit string ctor; no default port to ensure one is specified. 2017-11-30 11:23:47 -08:00
net.h ircd::net: Develop interface for async_wait / waiting on socket. 2018-01-08 13:25:13 -08:00
open.h ircd::net: Kill implicit conversion. 2018-01-08 03:08:59 -08:00
read.h ircd::net: Add discard_all() convenience. 2018-01-11 22:02:33 -08:00
README.md ircd::net: Refine network subsystem; break up interfaces; various. 2018-01-06 23:27:01 -08:00
remote.h ircd::net: Improve remote construction; hostport/ipport related. 2018-01-10 01:20:16 -08:00
resolve.h ircd::net: Improve resolver interface. 2018-01-04 17:44:34 -08:00
sock_opts.h ircd::net: Rename sockopts to sock_opts. 2018-01-07 02:02:41 -08:00
socket.h ircd::net: Tighten assumptions on cancel(). 2018-01-11 22:02:33 -08:00
wait.h ircd::net: Improve wait related; fix issues with bad behavior. 2018-01-08 18:33:05 -08:00
write.h ircd::net: Refine network subsystem; break up interfaces; various. 2018-01-06 23:27:01 -08:00

IRCd Networking

open()

The open() call combines DNS resolution, TCP connecting and SSL handshaking. A dedicated options structure is provided to tweak the specifics of the process.

close()

Like the open() sequence, the close() sequence composes a complex of multiple operations to close_notify the SSL session with cryptographic soundness and then disconnect the TCP session. A dedicated options structure is provided to tweak details.

read()

To keep things simple, this system has no notion of non-blocking or even asynchronous reads. In other words, you call read() when you know there is something to be read(). If there is nothing your ircd::ctx will yield until the call is interrupted/canceled by some timeout etc (which is something you might want too in certain contexts).

There are two possibilities: either the remote is faster than us or they are slower than us.

  • If the remote is faster than us, or faster than we want: we'll know data is available but ignore it to slow them down (by not calling read()) -- a matter in which we may not have a choice anyway.

  • If the remote is slower than us: you have to use a timer to put a limit on how much time (and resource) is going to be spent on receiving their data; eventually the daemon has to move on to serving other clients.

write()

This system uses two different techniques for sending data to remotes intended for two different categories of transmission:

  • write_all() is an intuitive synchronous send which yields the ircd::ctx until all bytes have been written to the remote. This is intended for serving simple requests or most other ctx-per-client models. A coarse timer is generally used to prevent the remote from being too slow to receive but we have some tolerance to wait a little for them.

  • write_any()/write_one() is a non-blocking send intended for small message mass-push models or some other custom flow control on larger messages. The goal here is to figure out what to do when the socket buffer has filled up because the remote has been too slow to receive data. The choice is usually to either propagate the slowdown to the source or to drop the remote so the daemon can move on without using up memory.