InspIRCd
3.0
|
#include <socketengine.h>
Classes | |
class | Statistics |
Public Types | |
typedef iovec | IOVector |
Static Public Member Functions | |
static void | Init () |
static void | Deinit () |
static bool | AddFd (EventHandler *eh, int event_mask) |
static void | ChangeEventMask (EventHandler *eh, int event_mask) |
static size_t | GetMaxFds () |
static size_t | GetUsedFds () |
static void | DelFd (EventHandler *eh) |
static bool | HasFd (int fd) |
static EventHandler * | GetRef (int fd) |
static int | DispatchEvents () |
static void | DispatchTrialWrites () |
static bool | BoundsCheckFd (EventHandler *eh) |
static int | Accept (EventHandler *fd, sockaddr *addr, socklen_t *addrlen) |
static int | Close (EventHandler *eh) |
static int | Close (int fd) |
static int | Send (EventHandler *fd, const void *buf, size_t len, int flags) |
static int | WriteV (EventHandler *fd, const IOVector *iov, int count) |
static int | Recv (EventHandler *fd, void *buf, size_t len, int flags) |
static int | RecvFrom (EventHandler *fd, void *buf, size_t len, int flags, sockaddr *from, socklen_t *fromlen) |
static int | SendTo (EventHandler *fd, const void *buf, size_t len, int flags, const irc::sockets::sockaddrs &address) |
static int | Connect (EventHandler *fd, const irc::sockets::sockaddrs &address) |
static int | Blocking (int fd) |
static int | NonBlocking (int fd) |
static int | Shutdown (EventHandler *fd, int how) |
static int | Shutdown (int fd, int how) |
static int | Bind (int fd, const irc::sockets::sockaddrs &addr) |
static int | Listen (int sockfd, int backlog) |
static void | SetReuse (int sockfd) |
static void | RecoverFromFork () |
static const Statistics & | GetStats () |
static bool | IgnoreError () |
static std::string | LastError () |
static std::string | GetError (int errnum) |
Provides basic file-descriptor-based I/O support. The actual socketengine class presents the same interface on all operating systems, but its private members and internal behaviour should be treated as blackboxed, and vary from system to system and upon the config settings chosen by the server admin.
|
static |
Abstraction for BSD sockets accept(2). This function should emulate its namesake system call exactly.
fd | This version of the call takes an EventHandler instead of a bare file descriptor. |
addr | The client IP address and port |
addrlen | The size of the sockaddr parameter. |
|
static |
Add an EventHandler object to the engine. Use AddFd to add a file descriptor to the engine and have the socket engine monitor it. You must provide an object derived from EventHandler which implements the required OnEventHandler*() methods.
eh | An event handling object to add |
event_mask | The initial event mask for the object |
|
static |
Abstraction for BSD sockets bind(2). This function should emulate its namesake system call exactly.
|
static |
Make a file descriptor blocking.
fd | a file descriptor to set to blocking mode |
|
static |
Returns true if the file descriptors in the given event handler are within sensible ranges which can be handled by the socket engine.
|
static |
If you call this function and pass it an event handler, that event handler will receive the next available write event, even if the socket is a readable socket only. Developers should avoid constantly keeping an eventhandler in the writeable state, as this will consume large amounts of CPU time.
eh | The event handler to change |
event_mask | The changes to make to the wait state |
|
static |
Close the underlying fd of an event handler, remove it from the socket engine and set the fd to -1.
eh | The EventHandler to close. |
|
static |
Abstraction for BSD sockets close(2). This function should emulate its namesake system call exactly. This function should emulate its namesake system call exactly.
|
static |
Abstraction for BSD sockets connect(2). This function should emulate its namesake system call exactly.
fd | This version of the call takes an EventHandler instead of a bare file descriptor. |
address | The server IP address and port. |
|
static |
Destructor. The destructor transparently tidies up any resources used by the socket engine.
Shutdown the kqueue engine
|
static |
Delete an event handler from the engine. This function call deletes an EventHandler from the engine, returning true if it succeeded and false if it failed. This does not free the EventHandler pointer using delete, if this is required you must do this yourself.
eh | The event handler object to remove |
|
static |
Waits for events and dispatches them to handlers. Please note that this doesn't wait long, only a couple of milliseconds. It returns the number of events which occurred during this call. This method will dispatch events to their handlers by calling their EventHandler::OnEventHandler*() methods.
|
static |
Dispatch trial reads and writes. This causes the actual socket I/O to happen when writes have been pre-buffered.
|
static |
Returns the error for the given error num, strerror(errnum) on *nix
|
inlinestatic |
Returns the number of file descriptors reported by the system this program may use when it was started.
|
static |
Returns the EventHandler attached to a specific fd. If the fd isn't in the socketengine, returns NULL.
fd | The event handler to look for |
|
inlinestatic |
Get data transfer and event statistics
|
inlinestatic |
Returns the number of file descriptors being queried
|
static |
Returns true if a file descriptor exists in the socket engine's list.
fd | The event handler to look for |
|
inlinestatic |
Should we ignore the error in errno? Checks EAGAIN and WSAEWOULDBLOCK
|
static |
Constructor. The constructor transparently initializes the socket engine which the ircd is using. Please note that if there is a catastrophic failure (for example, you try and enable epoll on a 2.4 linux kernel) then this function may bail back to the shell.
Initialize the kqueue engine
|
static |
Return the last socket related error. strrerror(errno) on *nix
|
static |
Abstraction for BSD sockets listen(2). This function should emulate its namesake system call exactly.
|
static |
Make a file descriptor nonblocking.
fd | A file descriptor to set to nonblocking mode |
|
static |
This function is called immediately after fork(). Some socket engines (notably kqueue) cannot have their handles inherited by forked processes. This method allows for the socket engine to re-create its handle after the daemon forks as the socket engine is created long BEFORE the daemon forks.
|
static |
Abstraction for BSD sockets recv(2). This function should emulate its namesake system call exactly.
fd | This version of the call takes an EventHandler instead of a bare file descriptor. |
buf | The buffer in which the data that is read is stored. |
len | The size of the buffer. |
flags | A flag value that controls the reception of the data. |
|
static |
Abstraction for BSD sockets recvfrom(2). This function should emulate its namesake system call exactly.
fd | This version of the call takes an EventHandler instead of a bare file descriptor. |
buf | The buffer in which the data that is read is stored. |
len | The size of the buffer. |
flags | A flag value that controls the reception of the data. |
from | The remote IP address and port. |
fromlen | The size of the from parameter. |
|
static |
Abstraction for BSD sockets send(2). This function should emulate its namesake system call exactly.
fd | This version of the call takes an EventHandler instead of a bare file descriptor. |
buf | The buffer in which the data that is sent is stored. |
len | The size of the buffer. |
flags | A flag value that controls the sending of the data. |
|
static |
Abstraction for BSD sockets sendto(2). This function should emulate its namesake system call exactly.
fd | This version of the call takes an EventHandler instead of a bare file descriptor. |
buf | The buffer in which the data that is sent is stored. |
len | The size of the buffer. |
flags | A flag value that controls the sending of the data. |
address | The remote IP address and port. |
|
static |
Set SO_REUSEADDR and SO_LINGER on this file descriptor
|
static |
Abstraction for BSD sockets shutdown(2). This function should emulate its namesake system call exactly.
fd | This version of the call takes an EventHandler instead of a bare file descriptor. |
how | What part of the socket to shut down |
|
static |
Abstraction for BSD sockets shutdown(2). This function should emulate its namesake system call exactly.
|
static |
Abstraction for vector write function writev(). This function should emulate its namesake system call exactly.
fd | EventHandler to send data with |
iov | Array of IOVectors containing the buffers to send and their lengths in the platform's native format. |
count | Number of elements in iov. |