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 };
36 InspSocketState state;
45 InspSocket(std::string host, int port, bool listening, unsigned long maxtime);
46 virtual bool OnConnected();
47 virtual void OnError(InspSocketError e);
48 virtual int OnDisconnect();
49 virtual bool OnDataReady();
50 virtual void OnTimeout();
51 virtual void OnClose();
53 virtual int Write(std::string data);
54 virtual int OnIncomingConnection();
55 void SetState(InspSocketState s);
58 virtual ~InspSocket();