+ /** Make a socket file descriptor a blocking socket
+ * @param s A valid file descriptor
+ */
+ void Blocking(int s);
+
+ /** Make a socket file descriptor into a nonblocking socket
+ * @param s A valid file descriptor
+ */
+ void NonBlocking(int s);
+
+ /** Create a new valid file descriptor using socket()
+ * @return On return this function will return a value >= 0 for success,
+ * or a negative value upon failure (negative values are invalid file
+ * descriptors)
+ */
+ int OpenTCPSocket(char* addr, int socktype = SOCK_STREAM);
+ };
+};
+
+/** This class handles incoming connections on client ports.
+ * It will create a new userrec for every valid connection
+ * and assign it a file descriptor.
+ */
+class ListenSocket : public EventHandler
+{
+ protected:
+ /** The creator/owner of this object
+ */
+ InspIRCd* ServerInstance;
+ std::string desc;
+ int family;
+ public:
+ /** Create a new listening socket
+ */
+ ListenSocket(InspIRCd* Instance, int sockfd, irc::sockets::insp_sockaddr client, irc::sockets::insp_sockaddr server, int port, char* addr);
+ /** Handle an I/O event
+ */
+ void HandleEvent(EventType et, int errornum = 0);
+ /** Close the socket
+ */
+ ~ListenSocket();
+ /** Set descriptive text
+ */
+ void SetDescription(const std::string &description)
+ {
+ desc = description;
+ }