1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 #ifndef __INSP_SOCKET_H__
18 #define __INSP_SOCKET_H__
20 #include <sys/types.h>
21 #include <sys/socket.h>
22 #include <netinet/in.h>
27 enum InspSocketState { I_DISCONNECTED, I_CONNECTING, I_CONNECTED, I_LISTENING, I_ERROR };
28 enum InspSocketError { I_ERR_TIMEOUT, I_ERR_SOCKET, I_ERR_CONNECT, I_ERR_BIND };
36 InspSocketState state;
49 InspSocket(int newfd, char* ip);
50 InspSocket(std::string host, int port, bool listening, unsigned long maxtime);
51 virtual bool OnConnected();
52 virtual void OnError(InspSocketError e);
53 virtual int OnDisconnect();
54 virtual bool OnDataReady();
55 virtual void OnTimeout();
56 virtual void OnClose();
59 virtual int Write(std::string data);
60 virtual int OnIncomingConnection(int newfd, char* ip);
61 void SetState(InspSocketState s);
62 InspSocketState GetState();
65 virtual ~InspSocket();