aboutsummaryrefslogtreecommitdiff
path: root/dep/include/sockets/ISocketHandler.h
diff options
context:
space:
mode:
Diffstat (limited to 'dep/include/sockets/ISocketHandler.h')
-rw-r--r--dep/include/sockets/ISocketHandler.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/dep/include/sockets/ISocketHandler.h b/dep/include/sockets/ISocketHandler.h
index 4bc72949e5e..bb1aa42bafc 100644
--- a/dep/include/sockets/ISocketHandler.h
+++ b/dep/include/sockets/ISocketHandler.h
@@ -4,20 +4,25 @@
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
+
This library is made available under the terms of the GNU GPL.
+
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -25,13 +30,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _SOCKETS_ISocketHandler_H
#define _SOCKETS_ISocketHandler_H
#include "sockets-config.h"
+
#include <list>
+
#include "socket_include.h"
#include "Socket.h"
#include "StdLog.h"
+
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
+
typedef enum {
LIST_CALLONCONNECT = 0,
#ifdef ENABLE_DETACH
@@ -41,14 +50,17 @@ typedef enum {
LIST_RETRY,
LIST_CLOSE
} list_t;
+
class SocketAddress;
class Mutex;
+
/** Socket container class, event generator.
\ingroup basic */
class ISocketHandler
{
friend class Socket;
+
public:
/** Connection pool class for internal use by the ISocketHandler.
\ingroup internal */
@@ -60,22 +72,29 @@ public:
CopyConnection( src );
SetIsClient();
}
+
void OnRead() {
Handler().LogError(this, "OnRead", 0, "data on hibernating socket", LOG_LEVEL_FATAL);
SetCloseAndDelete();
}
void OnOptions(int,int,int,SOCKET) {}
+
};
#endif
+
public:
virtual ~ISocketHandler() {}
+
/** Get mutex reference for threadsafe operations. */
virtual Mutex& GetMutex() const = 0;
+
/** Register StdLog object for error callback.
\param log Pointer to log class */
virtual void RegStdLog(StdLog *log) = 0;
+
/** Log error to log class for print out / storage. */
virtual void LogError(Socket *p,const std::string& user_text,int err,const std::string& sys_err,loglevel_t t = LOG_LEVEL_WARNING) = 0;
+
// -------------------------------------------------------------------------
// Socket stuff
// -------------------------------------------------------------------------
@@ -89,21 +108,26 @@ public:
virtual void Get(SOCKET s,bool& r,bool& w,bool& e) = 0;
/** Set read/write/exception file descriptor sets (fd_set). */
virtual void Set(SOCKET s,bool bRead,bool bWrite,bool bException = true) = 0;
+
/** Wait for events, generate callbacks. */
virtual int Select(long sec,long usec) = 0;
/** This method will not return until an event has been detected. */
virtual int Select() = 0;
/** Wait for events, generate callbacks. */
virtual int Select(struct timeval *tsel) = 0;
+
/** Check that a socket really is handled by this socket handler. */
virtual bool Valid(Socket *) = 0;
/** Return number of sockets handled by this handler. */
virtual size_t GetCount() = 0;
+
/** Override and return false to deny all incoming connections.
\param p ListenSocket class pointer (use GetPort to identify which one) */
virtual bool OkToAccept(Socket *p) = 0;
+
/** Called by Socket when a socket changes state. */
virtual void AddList(SOCKET s,list_t which_one,bool add) = 0;
+
// -------------------------------------------------------------------------
// Connection pool
// -------------------------------------------------------------------------
@@ -116,6 +140,7 @@ public:
\return true if connection pool is enabled */
virtual bool PoolEnabled() = 0;
#endif // ENABLE_POOL
+
// -------------------------------------------------------------------------
// Socks4
// -------------------------------------------------------------------------
@@ -143,6 +168,7 @@ public:
\return true if direct connection should be tried if connection to socks4 server fails */
virtual bool Socks4TryDirect() = 0;
#endif // ENABLE_SOCKS4
+
// -------------------------------------------------------------------------
// DNS resolve server
// -------------------------------------------------------------------------
@@ -172,6 +198,7 @@ public:
/** Returns true if socket waiting for a resolve event. */
virtual bool Resolving(Socket *) = 0;
#endif // ENABLE_RESOLVER
+
#ifdef ENABLE_TRIGGERS
/** Fetch unique trigger id. */
virtual int TriggerID(Socket *src) = 0;
@@ -186,16 +213,21 @@ public:
Leave them in place if 'false' - if a trigger should be called many times */
virtual void Trigger(int id, Socket::TriggerData& data, bool erase = true) = 0;
#endif // ENABLE_TRIGGERS
+
#ifdef ENABLE_DETACH
/** Indicates that the handler runs under SocketThread. */
virtual void SetSlave(bool x = true) = 0;
/** Indicates that the handler runs under SocketThread. */
virtual bool IsSlave() = 0;
#endif // ENABLE_DETACH
+
};
+
#ifdef SOCKETS_NAMESPACE
}
#endif
+
#endif // _SOCKETS_ISocketHandler_H
+