+ /** Socket description (shown in stats p) */
+ std::string desc;
+
+ /** Raw address socket is bound to */
+ std::string bind_addr;
+ /** Port socket is bound to */
+ int bind_port;
+ /** Human-readable address/port socket is bound to */
+ std::string bind_desc;
+
+ /** The client address if the most recently connected client.
+ * Should only be used when accepting a new client.
+ */
+ static irc::sockets::sockaddrs client;
+ /** The server address used by the most recently connected client.
+ * This may differ from the bind address by having a nonzero address,
+ * if the port is wildcard bound, or being IPv4 on a 6to4 IPv6 port.
+ * The address family will always match that of "client"
+ */
+ static irc::sockets::sockaddrs server;
+
+ public:
+ /** Create a new listening socket
+ */
+ ListenSocketBase(int port, const std::string &addr);
+ /** Handle an I/O event
+ */
+ void HandleEvent(EventType et, int errornum = 0);
+ /** Close the socket
+ */
+ ~ListenSocketBase();
+ /** Set descriptive text
+ */
+ void SetDescription(const std::string &description)
+ {
+ desc = description;
+ }
+ /** Get description for socket
+ */
+ const std::string& GetDescription() { return desc; }
+ /** Get port number for socket
+ */
+ int GetPort() const { return bind_port; }
+
+ /** Get IP address socket is bound to
+ */
+ const std::string &GetIP() { return bind_addr; }
+
+ const std::string &GetBindDesc() { return bind_desc; }
+
+ /** Handles sockets internals crap of a connection, convenience wrapper really
+ */
+ void AcceptInternal();
+
+ /** Called when a new connection has successfully been accepted on this listener.
+ * @param fd The file descriptor of the new connection
+ */
+ virtual void OnAcceptReady(int fd) = 0;
+};
+
+class CoreExport ClientListenSocket : public ListenSocketBase
+{
+ virtual void OnAcceptReady(int fd);