C++ Sockets Library documentation

C++ Sockets Library

Name of changed file

Version and , fileVersion and , file
Line 1 in Line 1 in
Context line
Removed line
Changed line
Context line
Context line
Changed line
Added line
Context line

Base64.h

/usr/src/Sockets-2.1.3/Base64.h 2007-04-15 07:11:50.0, 0200/usr/src/Sockets-2.1.4/Base64.h 2007-05-10 15:02:21.0, 0200
Line 28 in Base64.hLine 28 in Base64.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _BASE64_H
#define _BASE64_H
#ifdef _WIN32
#pragma warning(disable:4514)
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Base64_H
#define _SOCKETS_Base64_H
#include "sockets-config.h"
#ifdef _WIN32
#pragma warning(disable:4514)
Line 72 in Base64.hLine 73 in Base64.h
#endif
#endif // _BASE64_H
#endif
#endif // _SOCKETS_Base64_H

CircularBuffer.h

/usr/src/Sockets-2.1.3/CircularBuffer.h 2007-04-21 06:55:03.0, 0200/usr/src/Sockets-2.1.4/CircularBuffer.h 2007-05-10 15:02:38.0, 0200
Line 28 in CircularBuffer.hLine 28 in CircularBuffer.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _CIRCULARBUFFER_H
#define _CIRCULARBUFFER_H
#include <string>
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_CircularBuffer_H
#define _SOCKETS_CircularBuffer_H
#include "sockets-config.h"
#include <string>
Line 91 in CircularBuffer.hLine 92 in CircularBuffer.h
#endif // _CIRCULARBUFFER_H
#endif // _SOCKETS_CircularBuffer_H

CTcpSocket.h

/usr/src/Sockets-2.1.3/CTcpSocket.h 2007-04-15 07:11:51.0, 0200/usr/src/Sockets-2.1.4/CTcpSocket.h 2007-05-10 15:02:29.0, 0200
Line 28 in CTcpSocket.hLine 28 in CTcpSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _CTCPSOCKET_H
#define _CTCPSOCKET_H
#include "TcpSocket.h"
#include "ICrypt.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_CTcpSocket_H
#define _SOCKETS_CTcpSocket_H
#include "sockets-config.h"
#include "TcpSocket.h"
#include "ICrypt.h"
Line 68 in CTcpSocket.hLine 69 in CTcpSocket.h
#endif
#endif // _CTCPSOCKET_H
#endif
#endif // _SOCKETS_CTcpSocket_H

Event.h

/usr/src/Sockets-2.1.3/Event.h 2007-04-15 07:11:53.0, 0200/usr/src/Sockets-2.1.4/Event.h 2007-05-10 15:02:46.0, 0200
Line 28 in Event.hLine 28 in Event.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _EVENT_H
#define _EVENT_H
#ifdef _WIN32
#else
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Event_H
#define _SOCKETS_Event_H
#include "sockets-config.h"
#ifdef _WIN32
#else
Line 72 in Event.hLine 73 in Event.h
#endif
#endif // _EVENT_H
#endif
#endif // _SOCKETS_Event_H

EventHandler.cpp

/usr/src/Sockets-2.1.3/EventHandler.cpp 2007-04-21 07:20:18.0, 0200/usr/src/Sockets-2.1.4/EventHandler.cpp 2007-05-10 15:06:43.0, 0200
Line 35 in EventHandler.cppLine 35 in EventHandler.cpp
#include "Event.h"
#include "Socket.h"
#include "EventSocket.h"
#include "ListenSocket.h"
#include "Event.h"
#include "Socket.h"
#include "TcpSocket.h"
#include "ListenSocket.h"
Line 60 in EventHandler.cppLine 60 in EventHandler.cpp
std::list<Event *>::iterator it = m_events.begin();
Event *e = *it;
e -> GetFrom() -> SetHandlerInvalid();
delete e;
m_events.erase(it);
Line 75 in EventHandler.cppLine 76 in EventHandler.cpp
EventTime now;
mytime_t diff = (*it) -> GetTime() - now;
if (diff < 1)
{
diff = 1;
}
tv -> tv_sec = static_cast<long>(diff / 1000000);
tv -> tv_usec = static_cast<long>(diff % 1000000);
Line 99 in EventHandler.cppLine 104 in EventHandler.cpp
{
e -> GetFrom() -> OnEvent(e -> GetID());
e -> GetFrom() -> Decrease();
}
delete e;
Line 120 in EventHandler.cppLine 126 in EventHandler.cpp
m_socket -> Send("\n");
}
from -> Increase();
return e -> GetID();
}
Line 138 in EventHandler.cppLine 145 in EventHandler.cpp
m_events.erase(it);
repeat = true;
from -> Decrease();
break;
}
Line 188 in EventHandler.cppLine 196 in EventHandler.cpp
if (!m_socket)
{
ListenSocket<EventSocket> *l = new ListenSocket<EventSocket>(*this);
l -> SetDeleteByHandler();
l -> Bind("127.0.0.1", 0);
m_port = l -> GetPort();
SocketHandler::Add(l);
m_socket = new EventSocket( *this );
m_socket -> SetDeleteByHandler();
m_socket -> SetConnectTimeout(5);
if (!m_socket)
{
ListenSocket<TcpSocket> *l = new ListenSocket<TcpSocket>(*this);
l -> SetDeleteByHandler();
l -> Bind("127.0.0.1", 0);
m_port = l -> GetPort();
SocketHandler::Add(l);
m_socket = new TcpSocket( *this );
m_socket -> SetDeleteByHandler();
m_socket -> SetConnectTimeout(5);

EventHandler.h

/usr/src/Sockets-2.1.3/EventHandler.h 2007-04-15 07:11:55.0, 0200/usr/src/Sockets-2.1.4/EventHandler.h 2007-05-10 15:02:53.0, 0200
Line 28 in EventHandler.hLine 28 in EventHandler.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _EVENTHANDLER_H
#define _EVENTHANDLER_H
#include "SocketHandler.h"
#include "IEventHandler.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_EventHandler_H
#define _SOCKETS_EventHandler_H
#include "sockets-config.h"
#include "SocketHandler.h"
#include "IEventHandler.h"
Line 42 in EventHandler.hLine 43 in EventHandler.h
class IEventOwner;
class Event;
class EventSocket;
/** SocketHandler implementing the IEventHandler interface.
class IEventOwner;
class Event;
class TcpSocket;
/** SocketHandler implementing the IEventHandler interface.
Line 71 in EventHandler.hLine 72 in EventHandler.h
std::list<Event *> m_events;
bool m_quit;
EventSocket *m_socket;
port_t m_port;
};
std::list<Event *> m_events;
bool m_quit;
TcpSocket *m_socket;
port_t m_port;
};
Line 81 in EventHandler.hLine 82 in EventHandler.h
#endif
#endif // _EVENTHANDLER_H
#endif
#endif // _SOCKETS_EventHandler_H

EventTime.h

/usr/src/Sockets-2.1.3/EventTime.h 2007-04-15 07:12:17.0, 0200/usr/src/Sockets-2.1.4/EventTime.h 2007-05-10 15:03:00.0, 0200
Line 28 in EventTime.hLine 28 in EventTime.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_EVENTTIME_H
#define _SOCKETS_EVENTTIME_H
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_EventTime_H
#define _SOCKETS_EventTime_H
#include "sockets-config.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
Line 73 in EventTime.hLine 74 in EventTime.h
#endif
#endif // _SOCKETS_EVENTTIME_H
#endif
#endif // _SOCKETS_EventTime_H

File.h

/usr/src/Sockets-2.1.3/File.h 2007-04-15 07:12:19.0, 0200/usr/src/Sockets-2.1.4/File.h 2007-05-10 15:03:08.0, 0200
Line 28 in File.hLine 28 in File.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_FILE_H
#define _SOCKETS_FILE_H
#include "IFile.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_File_H
#define _SOCKETS_File_H
#include "sockets-config.h"
#include "IFile.h"
Line 74 in File.hLine 75 in File.h
#endif
#endif // _SOCKETS_FILE_H
#endif
#endif // _SOCKETS_File_H

HttpClientSocket.h

/usr/src/Sockets-2.1.3/HttpClientSocket.h 2007-04-15 07:18:48.0, 0200/usr/src/Sockets-2.1.4/HttpClientSocket.h 2007-05-10 15:03:24.0, 0200
Line 21 in HttpClientSocket.hLine 21 in HttpClientSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _HTTPCLIENTSOCKET_H
#define _HTTPCLIENTSOCKET_H
#include "HTTPSocket.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_HttpClientSocket_H
#define _SOCKETS_HttpClientSocket_H
#include "sockets-config.h"
#include "HTTPSocket.h"
Line 116 in HttpClientSocket.hLine 117 in HttpClientSocket.h
} // namespace SOCKETS_NAMESPACE {
#endif
#endif // _HTTPCLIENTSOCKET_H
} // namespace SOCKETS_NAMESPACE {
#endif
#endif // _SOCKETS_HttpClientSocket_H

HttpdCookies.h

/usr/src/Sockets-2.1.3/HttpdCookies.h 2007-04-15 07:12:28.0, 0200/usr/src/Sockets-2.1.4/HttpdCookies.h 2007-05-10 15:03:49.0, 0200
Line 27 in HttpdCookies.hLine 27 in HttpdCookies.h
*/
#ifndef _COOKIES_H
#define _COOKIES_H
#include <list>
#include <string>
*/
#ifndef _SOCKETS_HttpdCookies_H
#define _SOCKETS_HttpdCookies_H
#include "sockets-config.h"
#include <list>
#include <string>
Line 89 in HttpdCookies.hLine 90 in HttpdCookies.h
#endif
#endif // _COOKIES_H
#endif
#endif // _SOCKETS_HttpdCookies_H

HttpDebugSocket.h

/usr/src/Sockets-2.1.3/HttpDebugSocket.h 2007-04-15 07:12:23.0, 0200/usr/src/Sockets-2.1.4/HttpDebugSocket.h 2007-05-10 15:03:29.0, 0200
Line 27 in HttpDebugSocket.hLine 27 in HttpDebugSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _HttpDebugSocket_H
#define _HttpDebugSocket_H
#include "HTTPSocket.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_HttpDebugSocket_H
#define _SOCKETS_HttpDebugSocket_H
#include "sockets-config.h"
#include "HTTPSocket.h"
Line 66 in HttpDebugSocket.hLine 67 in HttpDebugSocket.h
#endif
#endif // _HttpDebugSocket_H
#endif
#endif // _SOCKETS_HttpDebugSocket_H

HttpdForm.h

/usr/src/Sockets-2.1.3/HttpdForm.h 2007-04-29 16:38:59.0, 0200/usr/src/Sockets-2.1.4/HttpdForm.h 2007-05-10 15:03:54.0, 0200
Line 30 in HttpdForm.hLine 30 in HttpdForm.h
*/
#ifndef _FORM_H
#define _FORM_H
#include <string>
#include <list>
*/
#ifndef _SOCKETS_HttpdForm_H
#define _SOCKETS_HttpdForm_H
#include "sockets-config.h"
#include <string>
#include <list>
Line 113 in HttpdForm.hLine 114 in HttpdForm.h
#endif
#endif // _FORM_H
#endif
#endif // _SOCKETS_HttpdForm_H

HttpdSocket.h

/usr/src/Sockets-2.1.3/HttpdSocket.h 2007-04-15 07:12:31.0, 0200/usr/src/Sockets-2.1.4/HttpdSocket.h 2007-05-10 15:04:00.0, 0200
Line 26 in HttpdSocket.hLine 26 in HttpdSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _HTTPDSOCKET_H
#define _HTTPDSOCKET_H
#include "HTTPSocket.h"
#include "ISocketHandler.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_HttpdSocket_H
#define _SOCKETS_HttpdSocket_H
#include "sockets-config.h"
#include "HTTPSocket.h"
#include "ISocketHandler.h"
Line 96 in HttpdSocket.hLine 97 in HttpdSocket.h
#endif
#endif // _HTTPDSOCKET_H
#endif
#endif // _SOCKETS_HttpdSocket_H

HttpGetSocket.h

/usr/src/Sockets-2.1.3/HttpGetSocket.h 2007-04-15 07:12:24.0, 0200/usr/src/Sockets-2.1.4/HttpGetSocket.h 2007-05-10 15:03:34.0, 0200
Line 28 in HttpGetSocket.hLine 28 in HttpGetSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _HTTPGETSOCKET_H
#define _HTTPGETSOCKET_H
#include "HttpClientSocket.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_HttpGetSocket_H
#define _SOCKETS_HttpGetSocket_H
#include "sockets-config.h"
#include "HttpClientSocket.h"
Line 62 in HttpGetSocket.hLine 63 in HttpGetSocket.h
#endif
#endif // _HTTPGETSOCKET_H
#endif
#endif // _SOCKETS_HttpGetSocket_H

HttpPostSocket.h

/usr/src/Sockets-2.1.3/HttpPostSocket.h 2007-04-15 07:12:25.0, 0200/usr/src/Sockets-2.1.4/HttpPostSocket.h 2007-05-10 15:03:39.0, 0200
Line 28 in HttpPostSocket.hLine 28 in HttpPostSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _HTTPPOSTSOCKET_H
#define _HTTPPOSTSOCKET_H
#include "HttpClientSocket.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_HttpPostSocket_H
#define _SOCKETS_HttpPostSocket_H
#include "sockets-config.h"
#include "HttpClientSocket.h"
Line 87 in HttpPostSocket.hLine 88 in HttpPostSocket.h
#endif
#endif // _HTTPPOSTSOCKET_H
#endif
#endif // _SOCKETS_HttpPostSocket_H

HttpPutSocket.h

/usr/src/Sockets-2.1.3/HttpPutSocket.h 2007-04-15 07:12:27.0, 0200/usr/src/Sockets-2.1.4/HttpPutSocket.h 2007-05-10 15:03:44.0, 0200
Line 28 in HttpPutSocket.hLine 28 in HttpPutSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _HTTPPUTSOCKET_H
#define _HTTPPUTSOCKET_H
#include "HttpClientSocket.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_HttpPutSocket_H
#define _SOCKETS_HttpPutSocket_H
#include "sockets-config.h"
#include "HttpClientSocket.h"
Line 79 in HttpPutSocket.hLine 80 in HttpPutSocket.h
#endif
#endif // _HTTPPUTSOCKET_H
#endif
#endif // _SOCKETS_HttpPutSocket_H

HTTPSocket.h

/usr/src/Sockets-2.1.3/HTTPSocket.h 2007-04-15 07:12:20.0, 0200/usr/src/Sockets-2.1.4/HTTPSocket.h 2007-05-10 15:03:16.0, 0200
Line 28 in HTTPSocket.hLine 28 in HTTPSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _HTTPSOCKET_H
#define _HTTPSOCKET_H
#include <map>
#include "TcpSocket.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_HTTPSocket_H
#define _SOCKETS_HTTPSocket_H
#include "sockets-config.h"
#include <map>
#include "TcpSocket.h"
Line 143 in HTTPSocket.hLine 144 in HTTPSocket.h
#endif
#endif // _HTTPSOCKET_H
#endif
#endif // _SOCKETS_HTTPSocket_H

ICrypt.h

/usr/src/Sockets-2.1.3/ICrypt.h 2007-04-20 21:29:01.0, 0200/usr/src/Sockets-2.1.4/ICrypt.h 2007-05-10 15:04:04.0, 0200
Line 28 in ICrypt.hLine 28 in ICrypt.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _ICRYPT_H
#define _ICRYPT_H
#include <string>
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_ICrypt_H
#define _SOCKETS_ICrypt_H
#include "sockets-config.h"
#include <string>
Line 47 in ICrypt.hLine 48 in ICrypt.h
#endif // _ICRYPT_H
#endif // _SOCKETS_ICrypt_H

IEventHandler.h

/usr/src/Sockets-2.1.3/IEventHandler.h 2007-04-15 07:12:34.0, 0200/usr/src/Sockets-2.1.4/IEventHandler.h 2007-05-10 15:04:19.0, 0200
Line 28 in IEventHandler.hLine 28 in IEventHandler.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _IEVENTHANDLER_H
#define _IEVENTHANDLER_H
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_IEventHandler_H
#define _SOCKETS_IEventHandler_H
#include "sockets-config.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
Line 70 in IEventHandler.hLine 71 in IEventHandler.h
#endif
#endif // _IEVENTHANDLER_H
#endif
#endif // _SOCKETS_IEventHandler_H

IEventOwner.cpp

/usr/src/Sockets-2.1.3/IEventOwner.cpp 2007-04-15 07:16:38.0, 0200/usr/src/Sockets-2.1.4/IEventOwner.cpp 2007-05-09 21:51:26.0, 0200
Line 36 in IEventOwner.cppLine 36 in IEventOwner.cpp
IEventOwner::IEventOwner(IEventHandler& h) : m_event_handler(h)
{
}
IEventOwner::IEventOwner(IEventHandler& h) : m_event_handler(h), m_handler_invalid(false), m_events(0)
{
}
Line 43 in IEventOwner.cppLine 43 in IEventOwner.cpp
IEventOwner::~IEventOwner()
{
if (m_events && !m_handler_invalid)
{
m_event_handler.ClearEvents(this);
}
}
Line 71 in IEventOwner.cppLine 74 in IEventOwner.cpp
void IEventOwner::Increase()
{
m_events++;
}
void IEventOwner::Decrease()
{
if (m_events)
m_events--;
}
#ifdef SOCKETS_NAMESPACE
}

IEventOwner.h

/usr/src/Sockets-2.1.3/IEventOwner.h 2007-04-15 07:12:35.0, 0200/usr/src/Sockets-2.1.4/IEventOwner.h 2007-05-10 15:04:23.0, 0200
Line 28 in IEventOwner.hLine 28 in IEventOwner.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _IEVENTOWNER_H
#define _IEVENTOWNER_H
#include "IEventHandler.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_IEventOwner_H
#define _SOCKETS_IEventOwner_H
#include "sockets-config.h"
#include "IEventHandler.h"
Line 60 in IEventOwner.hLine 61 in IEventOwner.h
IEventHandler& EventHandler();
void SetHandlerInvalid(bool x = true) { m_handler_invalid = x; }
void Increase();
void Decrease();
private:
IEventHandler& m_event_handler;
bool m_handler_invalid;
int m_events;
};
Line 71 in IEventOwner.hLine 78 in IEventOwner.h
#endif
#endif // _IEVENTOWNER_H
#endif
#endif // _SOCKETS_IEventOwner_H

IFile.h

/usr/src/Sockets-2.1.3/IFile.h 2007-04-15 07:12:37.0, 0200/usr/src/Sockets-2.1.4/IFile.h 2007-05-10 15:04:27.0, 0200
Line 28 in IFile.hLine 28 in IFile.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _IFILE_H
#define _IFILE_H
#include <string>
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_IFile_H
#define _SOCKETS_IFile_H
#include "sockets-config.h"
#include <string>
Line 63 in IFile.hLine 64 in IFile.h
#endif
#endif // _IFILE_H
#endif
#endif // _SOCKETS_IFile_H

Ipv4Address.h

/usr/src/Sockets-2.1.3/Ipv4Address.h 2007-04-15 07:36:20.0, 0200/usr/src/Sockets-2.1.4/Ipv4Address.h 2007-05-10 15:04:35.0, 0200
Line 21 in Ipv4Address.hLine 21 in Ipv4Address.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _IPV4ADDRESS_H
#define _IPV4ADDRESS_H
#include "SocketAddress.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Ipv4Address_H
#define _SOCKETS_Ipv4Address_H
#include "sockets-config.h"
#include "SocketAddress.h"
Line 94 in Ipv4Address.hLine 95 in Ipv4Address.h
} // namespace SOCKETS_NAMESPACE {
#endif
#endif // _IPV4ADDRESS_H
} // namespace SOCKETS_NAMESPACE {
#endif
#endif // _SOCKETS_Ipv4Address_H

Ipv6Address.h

/usr/src/Sockets-2.1.3/Ipv6Address.h 2007-04-22 21:10:22.0, 0200/usr/src/Sockets-2.1.4/Ipv6Address.h 2007-05-10 14:37:26.0, 0200
Line 21 in Ipv6Address.hLine 21 in Ipv6Address.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _IPV6ADDRESS_H
#define _IPV6ADDRESS_H
#include "sockets-config.h"
#ifdef ENABLE_IPV6
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Ipv6Address_H
#define _SOCKETS_Ipv6Address_H
#include "sockets-config.h"
#ifdef ENABLE_IPV6
Line 104 in Ipv6Address.hLine 104 in Ipv6Address.h
#endif // IPPROTO_IPV6
#endif // ENABLE_IPV6
#endif // _IPV6ADDRESS_H
#endif // IPPROTO_IPV6
#endif // ENABLE_IPV6
#endif // _SOCKETS_Ipv6Address_H

ISocketHandler.h

/usr/src/Sockets-2.1.3/ISocketHandler.h 2007-04-22 21:10:45.0, 0200/usr/src/Sockets-2.1.4/ISocketHandler.h 2007-05-10 14:59:49.0, 0200
Line 28 in ISocketHandler.hLine 28 in ISocketHandler.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _ISOCKETHANDLER_H
#define _ISOCKETHANDLER_H
#include "sockets-config.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_ISocketHandler_H
#define _SOCKETS_ISocketHandler_H
#include "sockets-config.h"
Line 38 in ISocketHandler.hLine 38 in ISocketHandler.h
#include "StdLog.h"
#include "Mutex.h"
#include "Socket.h"
#ifdef SOCKETS_NAMESPACE
Line 53 in ISocketHandler.hLine 54 in ISocketHandler.h
} list_t;
class PoolSocket;
class SocketAddress;
Line 64 in ISocketHandler.hLine 64 in ISocketHandler.h
public:
/** Connection pool class for internal use by the ISocketHandler.
\ingroup internal */
#ifdef ENABLE_POOL
class PoolSocket : public Socket
{
public:
PoolSocket(ISocketHandler& h,Socket *src) : Socket(h) {
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:
/** ISocketHandler constructor.
\param log Optional log class pointer */
Line 127 in ISocketHandler.hLine 148 in ISocketHandler.h
#ifdef ENABLE_POOL
/** Find available open connection (used by connection pool). */
virtual PoolSocket *FindConnection(int type,const std::string& protocol,SocketAddress&) {
return NULL;
}
#ifdef ENABLE_POOL
/** Find available open connection (used by connection pool). */
virtual ISocketHandler::PoolSocket *FindConnection(int type,const std::string& protocol,SocketAddress&) {
return NULL;
}
Line 229 in ISocketHandler.hLine 250 in ISocketHandler.h
#endif
#endif // _ISOCKETHANDLER_H
#endif
#endif // _SOCKETS_ISocketHandler_H

ListenSocket.h

/usr/src/Sockets-2.1.3/ListenSocket.h 2007-04-30 10:12:07.0, 0200/usr/src/Sockets-2.1.4/ListenSocket.h 2007-05-10 14:37:30.0, 0200
Line 28 in ListenSocket.hLine 28 in ListenSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _LISTENSOCKET_H
#define _LISTENSOCKET_H
#include "sockets-config.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_ListenSocket_H
#define _SOCKETS_ListenSocket_H
#include "sockets-config.h"
Line 387 in ListenSocket.hLine 387 in ListenSocket.h
// %! See bugfix for this in SocketHandler::Select - don't Set rwx
// %! flags if CloseAndDelete() flag is true.
// %! An even better fugbix (see TcpSocket::OnSSLAccept) now avoids
// %! the Add problem altogether, so ignore the above.
// %! (OnSSLAccept does no longer call SSLNegotiate().)
tmp -> OnSSLAccept();
}
Line 423 in ListenSocket.hLine 426 in ListenSocket.h
#endif
#endif // _LISTENSOCKET_H
#endif
#endif // _SOCKETS_ListenSocket_H

Lock.h

/usr/src/Sockets-2.1.3/Lock.h 2007-04-15 07:13:17.0, 0200/usr/src/Sockets-2.1.4/Lock.h 2007-05-10 15:04:43.0, 0200
Line 28 in Lock.hLine 28 in Lock.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_LOCK_H
#define _SOCKETS_LOCK_H
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Lock_H
#define _SOCKETS_Lock_H
#include "sockets-config.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
Line 55 in Lock.hLine 56 in Lock.h
}
#endif
#endif // _SOCKETS_LOCK_H
}
#endif
#endif // _SOCKETS_Lock_H

Makefile

/usr/src/Sockets-2.1.3/Makefile 2007-04-29 11:26:27.0, 0200/usr/src/Sockets-2.1.4/Makefile 2007-05-10 13:55:27.0, 0200
Line 78 in MakefileLine 78 in Makefile
@rm -f $(PREFIX)/include/Sockets/HttpsGetSocket.*
@rm -f $(PREFIX)/include/Sockets/HttpsSocket.*
@rm -f $(PREFIX)/include/Sockets/EventSocket.*
@rm -f $(PREFIX)/include/Sockets/PoolSocket.*
@rm -f $(PREFIX)/include/Sockets/SocketThread.*
@mkdir -p $(PREFIX)/bin
install Sockets-config $(PREFIX)/bin

Makefile.version

/usr/src/Sockets-2.1.3/Makefile.version 2007-04-30 10:25:03.0, 0200/usr/src/Sockets-2.1.4/Makefile.version 2007-05-10 15:14:43.0, 0200
Line 1 in Makefile.versionLine 1 in Makefile.version
VERSION = 2.1.3
DIFF_VERSION = 2.1.2
# Sockets
VERSION = 2.1.4
DIFF_VERSION = 2.1.3
# Sockets
Line 12 in Makefile.versionLine 12 in Makefile.version
HttpGetSocket.o \
HTTPSocket.o \
Thread.o SocketThread.o \
StdoutLog.o \
HttpPutSocket.o \
HttpGetSocket.o \
HTTPSocket.o \
Thread.o \
StdoutLog.o \
HttpPutSocket.o \
Line 18 in Makefile.versionLine 18 in Makefile.version
HttpDebugSocket.o \
Utility.o \
PoolSocket.o \
ResolvServer.o \
ResolvSocket.o \
Line 36 in Makefile.versionLine 35 in Makefile.version
Semaphore.o \
RandomNumber.o \
EventSocket.o \
SSLInitializer.o
# SocketsEx
Semaphore.o \
RandomNumber.o \
SSLInitializer.o \
SmtpdSocket.o
# SocketsEx

MemFile.h

/usr/src/Sockets-2.1.3/MemFile.h 2007-04-15 07:13:18.0, 0200/usr/src/Sockets-2.1.4/MemFile.h 2007-05-10 15:04:47.0, 0200
Line 28 in MemFile.hLine 28 in MemFile.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _MEMFILE_H
#define _MEMFILE_H
#include <map>
#include "IFile.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_MemFile_H
#define _SOCKETS_MemFile_H
#include "sockets-config.h"
#include <map>
#include "IFile.h"
Line 92 in MemFile.hLine 93 in MemFile.h
#endif
#endif // _MEMFILE_H
#endif
#endif // _SOCKETS_MemFile_H

MinderHandler.h

/usr/src/Sockets-2.1.3/MinderHandler.h 2007-04-21 01:06:46.0, 0200/usr/src/Sockets-2.1.4/MinderHandler.h 2007-05-10 13:43:13.0, 0200
Line 21 in MinderHandler.hLine 21 in MinderHandler.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _MINION_MINDERHANDLER_H
#define _MINION_MINDERHANDLER_H
#include "sockets-config.h"
#ifdef HAVE_OPENSSL
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _MINION_MinderHandler_H
#define _MINION_MinderHandler_H
#include "sockets-config.h"
#ifdef HAVE_OPENSSL
Line 152 in MinderHandler.hLine 152 in MinderHandler.h
#endif // HAVE_OPENSSL
#endif // _MINION_MINDERHANDLER_H
#endif // HAVE_OPENSSL
#endif // _MINION_MinderHandler_H

MinderSocket.h

/usr/src/Sockets-2.1.3/MinderSocket.h 2007-04-21 01:06:46.0, 0200/usr/src/Sockets-2.1.4/MinderSocket.h 2007-05-10 14:37:41.0, 0200
Line 21 in MinderSocket.hLine 21 in MinderSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _MINDERSOCKET_H
#define _MINDERSOCKET_H
#include "sockets-config.h"
#ifdef HAVE_OPENSSL
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_MinderSocket_H
#define _SOCKETS_MinderSocket_H
#include "sockets-config.h"
#ifdef HAVE_OPENSSL
Line 79 in MinderSocket.hLine 79 in MinderSocket.h
#endif // HAVE_OPENSSL
#endif // _MINDERSOCKET_H
#endif // HAVE_OPENSSL
#endif // _SOCKETS_MinderSocket_H

MinionSocket.h

/usr/src/Sockets-2.1.3/MinionSocket.h 2007-04-21 01:06:46.0, 0200/usr/src/Sockets-2.1.4/MinionSocket.h 2007-05-10 14:37:43.0, 0200
Line 21 in MinionSocket.hLine 21 in MinionSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _MINIONSOCKET_H
#define _MINIONSOCKET_H
#include "sockets-config.h"
#ifdef HAVE_OPENSSL
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_MinionSocket_H
#define _SOCKETS_MinionSocket_H
#include "sockets-config.h"
#ifdef HAVE_OPENSSL
Line 112 in MinionSocket.hLine 112 in MinionSocket.h
#endif // HAVE_OPENSSL
#endif // _MINIONSOCKET_H
#endif // HAVE_OPENSSL
#endif // _SOCKETS_MinionSocket_H

Mutex.h

/usr/src/Sockets-2.1.3/Mutex.h 2007-04-15 07:13:19.0, 0200/usr/src/Sockets-2.1.4/Mutex.h 2007-05-10 15:04:59.0, 0200
Line 28 in Mutex.hLine 28 in Mutex.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_MUTEX_H
#define _SOCKETS_MUTEX_H
#ifndef _WIN32
#include <pthread.h>
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Mutex_H
#define _SOCKETS_Mutex_H
#include "sockets-config.h"
#ifndef _WIN32
#include <pthread.h>
Line 64 in Mutex.hLine 65 in Mutex.h
}
#endif
#endif // _SOCKETS_MUTEX_H
}
#endif
#endif // _SOCKETS_Mutex_H

NullCrypt.h

/usr/src/Sockets-2.1.3/NullCrypt.h 2007-04-15 07:13:26.0, 0200/usr/src/Sockets-2.1.4/NullCrypt.h 2007-05-10 15:05:03.0, 0200
Line 28 in NullCrypt.hLine 28 in NullCrypt.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _NULLCRYPT_H
#define _NULLCRYPT_H
#include "ICrypt.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_NullCrypt_H
#define _SOCKETS_NullCrypt_H
#include "sockets-config.h"
#include "ICrypt.h"
Line 56 in NullCrypt.hLine 57 in NullCrypt.h
#endif
#endif // _NULLCRYPT_H
#endif
#endif // _SOCKETS_NullCrypt_H

Parse.h

/usr/src/Sockets-2.1.3/Parse.h 2007-04-15 07:13:29.0, 0200/usr/src/Sockets-2.1.4/Parse.h 2007-05-10 15:05:09.0, 0200
Line 30 in Parse.hLine 30 in Parse.h
*/
#ifndef _PARSE_H
#define _PARSE_H
#ifdef _WIN32
#pragma warning(disable:4514)
*/
#ifndef _SOCKETS_Parse_H
#define _SOCKETS_Parse_H
#include "sockets-config.h"
#ifdef _WIN32
#pragma warning(disable:4514)
Line 97 in Parse.hLine 98 in Parse.h
#endif
#endif // _PARSE_H
#endif
#endif // _SOCKETS_Parse_H

RandomNumber.h

/usr/src/Sockets-2.1.3/RandomNumber.h 2007-04-15 07:13:39.0, 0200/usr/src/Sockets-2.1.4/RandomNumber.h 2007-05-10 15:05:13.0, 0200
Line 19 in RandomNumber.hLine 19 in RandomNumber.h
*/
#ifndef RANDOM_NUMBER_H
#define RANDOM_NUMBER_H
#include <limits>
*/
#ifndef _SOCKET_RandomNumber_H
#define _SOCKET_RandomNumber_H
#include "sockets-config.h"
#include <limits>
Line 198 in RandomNumber.hLine 199 in RandomNumber.h
#endif
#endif
#endif
#endif // _SOCKETS_RandomNumber_H

ResolvServer.h

/usr/src/Sockets-2.1.3/ResolvServer.h 2007-04-17 15:15:58.0, 0200/usr/src/Sockets-2.1.4/ResolvServer.h 2007-05-10 14:37:54.0, 0200
Line 28 in ResolvServer.hLine 28 in ResolvServer.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _RESOLVSERVER_H
#define _RESOLVSERVER_H
#include "sockets-config.h"
#ifdef ENABLE_RESOLVER
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_ResolvServer_H
#define _SOCKETS_ResolvServer_H
#include "sockets-config.h"
#ifdef ENABLE_RESOLVER
Line 70 in ResolvServer.hLine 70 in ResolvServer.h
#endif // ENABLE_RESOLVER
#endif // _RESOLVSERVER_H
#endif // ENABLE_RESOLVER
#endif // _SOCKETS_ResolvServer_H

ResolvSocket.h

/usr/src/Sockets-2.1.3/ResolvSocket.h 2007-04-26 21:35:43.0, 0200/usr/src/Sockets-2.1.4/ResolvSocket.h 2007-05-10 14:37:56.0, 0200
Line 28 in ResolvSocket.hLine 28 in ResolvSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _RESOLVSOCKET_H
#define _RESOLVSOCKET_H
#include "sockets-config.h"
#ifdef ENABLE_RESOLVER
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_ResolvSocket_H
#define _SOCKETS_ResolvSocket_H
#include "sockets-config.h"
#ifdef ENABLE_RESOLVER
Line 90 in ResolvSocket.hLine 90 in ResolvSocket.h
#endif // ENABLE_RESOLVER
#endif // _RESOLVSOCKET_H
#endif // ENABLE_RESOLVER
#endif // _SOCKETS_ResolvSocket_H

SctpSocket.h

/usr/src/Sockets-2.1.3/SctpSocket.h 2007-04-15 07:27:29.0, 0200/usr/src/Sockets-2.1.4/SctpSocket.h 2007-05-10 13:45:12.0, 0200
Line 21 in SctpSocket.hLine 21 in SctpSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_NAMESPACE_SCTPSOCKET_H
#define _SOCKETS_NAMESPACE_SCTPSOCKET_H
#include "sockets-config.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_SctpSocket_H
#define _SOCKETS_SctpSocket_H
#include "sockets-config.h"
Line 93 in SctpSocket.hLine 93 in SctpSocket.h
#endif // USE_SCTP
#endif // _SOCKETS_NAMESPACE_SCTPSOCKET_H
#endif // USE_SCTP
#endif // _SOCKETS_SctpSocket_H

Semaphore.h

/usr/src/Sockets-2.1.3/Semaphore.h 2007-04-15 07:39:42.0, 0200/usr/src/Sockets-2.1.4/Semaphore.h 2007-05-10 15:05:25.0, 0200
Line 21 in Semaphore.hLine 21 in Semaphore.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_SEMAPHORE_H
#define _SOCKETS_SEMAPHORE_H
#include <pthread.h>
#include <semaphore.h>
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Semaphore_H
#define _SOCKETS_Semaphore_H
#include "sockets-config.h"
#include <pthread.h>
#include <semaphore.h>
Line 59 in Semaphore.hLine 60 in Semaphore.h
} // namespace SOCKETS_NAMESPACE {
#endif
#endif // _SOCKETS_SEMAPHORE_H
} // namespace SOCKETS_NAMESPACE {
#endif
#endif // _SOCKETS_Semaphore_H

SocketAddress.h

/usr/src/Sockets-2.1.3/SocketAddress.h 2007-04-15 07:36:28.0, 0200/usr/src/Sockets-2.1.4/SocketAddress.h 2007-05-10 15:05:37.0, 0200
Line 21 in SocketAddress.hLine 21 in SocketAddress.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETADDRESS_H
#define _SOCKETADDRESS_H
#include <string>
#include <memory>
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_SocketAddress_H
#define _SOCKETS_SocketAddress_H
#include "sockets-config.h"
#include <string>
#include <memory>
Line 92 in SocketAddress.hLine 93 in SocketAddress.h
} // namespace SOCKETS_NAMESPACE {
#endif
#endif // _SOCKETADDRESS_H
} // namespace SOCKETS_NAMESPACE {
#endif
#endif // _SOCKETS_SocketAddress_H

Socket.cpp

/usr/src/Sockets-2.1.3/Socket.cpp 2007-04-22 20:54:36.0, 0200/usr/src/Sockets-2.1.4/Socket.cpp 2007-05-10 13:54:57.0, 0200
Line 40 in Socket.cppLine 40 in Socket.cpp
#include "ISocketHandler.h"
#include "SocketThread.h"
#include "Utility.h"
#include "TcpSocket.h"
#include "SocketAddress.h"
#ifdef SOCKETS_NAMESPACE
#include "ISocketHandler.h"
#include "Utility.h"
#include "TcpSocket.h"
#include "SocketAddress.h"
#include "SocketHandler.h"
#ifdef _DEBUG
#define DEB(x) x; fflush(stderr);
#else
#define DEB(x)
#endif
#ifdef SOCKETS_NAMESPACE
Line 85 in Socket.cppLine 91 in Socket.cpp
,m_client_remote_address(NULL)
,m_remote_address(NULL)
,m_traffic_monitor(NULL)
#ifdef HAVE_OPENSSL
,m_b_enable_ssl(false)
Line 229 in Socket.cppLine 236 in Socket.cpp
int Socket::Close()
{
DEB( fprintf(stderr, " fd %d\n", m_socket);)
if (m_socket == INVALID_SOCKET) // this could happen
{
Line 236 in Socket.cppLine 244 in Socket.cpp
int n;
SetNonblocking(true);
if (IsConnected())
{
if (shutdown(m_socket, SHUT_WR) == -1)
int n;
SetNonblocking(true);
if (IsConnected() && !(GetShutdown() & SHUT_WR))
{
if (shutdown(m_socket, SHUT_WR) == -1)
Line 271 in Socket.cppLine 279 in Socket.cpp
Handler().AddList(m_socket, LIST_CLOSE, false);
m_socket = INVALID_SOCKET;
DEB( fprintf(stderr, " fd %d\n", m_socket);)
return n;
}
Line 592 in Socket.cppLine 601 in Socket.cpp
#ifdef ENABLE_DETACH
bool Socket::Detach()
{
if (!DeleteByHandler())
return false;
if (m_pThread)
return false;
if (m_detached)
return false;
SetDetach();
return true;
}
void Socket::DetachSocket()
{
SetDetached();
m_pThread = new SocketThread(this);
m_pThread -> SetRelease(true);
}
#endif
void Socket::OnLine(const std::string& )
{
Line 632 in Socket.cppLine 618 in Socket.cpp
/*
void Socket::ReadLine()
{
}
*/
void Socket::OnConnectFailed()
{
Line 668 in Socket.cppLine 647 in Socket.cpp
#ifdef ENABLE_POOL
void Socket::CopyConnection(Socket *sock)
{
Attach( sock -> GetSocket() );
#ifdef ENABLE_IPV6
SetIpv6( sock -> IsIpv6() );
#endif
SetSocketType( sock -> GetSocketType() );
SetSocketProtocol( sock -> GetSocketProtocol() );
/*
SocketAddress *client = sock -> GetClientRemoteAddress();
if (client)
{
SetClientRemoteAddress( *client );
}
*/
SetClientRemoteAddress( *sock -> GetClientRemoteAddress() );
/*
SocketAddress *remote = GetRemoteSocketAddress();
if (remote)
{
SetRemoteAddress(*remote);
}
*/
SetRemoteAddress( *sock -> GetRemoteSocketAddress() );
}
#endif
#ifdef ENABLE_RESOLVER
int Socket::Resolve(const std::string& host,port_t port)
{
return Handler().Resolve(this, host, port);
}
#ifdef ENABLE_IPV6
int Socket::Resolve6(const std::string& host,port_t port)
{
return Handler().Resolve6(this, host, port);
}
#endif
int Socket::Resolve(ipaddr_t a)
{
return Handler().Resolve(this, a);
}
#ifdef ENABLE_IPV6
int Socket::Resolve(in6_addr& a)
{
return Handler().Resolve(this, a);
}
#endif
#endif
#ifdef ENABLE_SOCKS4
void Socket::OnSocks4Connect()
{
Handler().LogError(this, "OnSocks4Connect", 0, "Use with TcpSocket only");
}
void Socket::OnSocks4ConnectFailed()
{
Handler().LogError(this, "OnSocks4ConnectFailed", 0, "Use with TcpSocket only");
}
bool Socket::OnSocks4Read()
{
Handler().LogError(this, "OnSocks4Read", 0, "Use with TcpSocket only");
return true;
}
void Socket::SetSocks4Host(const std::string& host)
{
Utility::u2ip(host, m_socks4_host);
}
#endif
/*
void Socket::OnWriteComplete()
{
}
*/
#ifdef ENABLE_RESOLVER
void Socket::OnResolved(int,ipaddr_t,port_t)
{
}
#ifdef ENABLE_IPV6
void Socket::OnResolved(int,in6_addr&,port_t)
{
}
#endif
void Socket::OnReverseResolved(int,const std::string&)
{
}
void Socket::OnResolveFailed(int)
{
}
#endif
Socket *Socket::Create()
{
return NULL;
}
#ifdef HAVE_OPENSSL
void Socket::OnSSLConnect()
{
}
void Socket::OnSSLAccept()
{
}
#endif
bool Socket::OnConnectRetry()
{
return true;
}
#ifdef ENABLE_RECONNECT
void Socket::OnReconnect()
{
}
#endif
#ifdef HAVE_OPENSSL
bool Socket::SSLNegotiate()
{
return false;
}
#endif
time_t Socket::Uptime()
{
return time(NULL) - m_tCreate;
}
#ifdef ENABLE_DETACH
void Socket::OnDetached()
{
}
void Socket::SetDetach(bool x)
{
Handler().AddList(m_socket, LIST_DETACH, x);
m_detach = x;
}
bool Socket::IsDetach()
{
return m_detach;
}
void Socket::SetDetached(bool x)
{
m_detached = x;
}
const bool Socket::IsDetached() const
{
return m_detached;
}
#endif
#ifdef ENABLE_IPV6
void Socket::SetIpv6(bool x)
{
m_ipv6 = x;
}
bool Socket::IsIpv6()
{
return m_ipv6;
}
#endif
#ifdef ENABLE_POOL
void Socket::SetIsClient()
{
m_bClient = true;
}
void Socket::SetSocketType(int x)
{
m_socket_type = x;
}
int Socket::GetSocketType()
{
return m_socket_type;
}
void Socket::SetSocketProtocol(const std::string& x)
{
m_socket_protocol = x;
}
const std::string& Socket::GetSocketProtocol()
{
return m_socket_protocol;
}
void Socket::SetRetain()
{
if (m_bClient) m_bRetain = true;
}
bool Socket::Retain()
{
return m_bRetain;
}
void Socket::SetLost()
{
m_bLost = true;
}
bool Socket::Lost()
{
return m_bLost;
}
#endif
void Socket::SetCallOnConnect(bool x)
{
Handler().AddList(m_socket, LIST_CALLONCONNECT, x);
m_call_on_connect = x;
}
bool Socket::CallOnConnect()
{
return m_call_on_connect;
}
void Socket::SetReuse(bool x)
{
m_opt_reuse = x;
}
void Socket::SetKeepalive(bool x)
{
m_opt_keepalive = x;
}
#ifdef ENABLE_SOCKS4
bool Socket::Socks4()
{
return m_bSocks4;
}
void Socket::SetSocks4(bool x)
{
m_bSocks4 = x;
}
void Socket::SetSocks4Host(ipaddr_t a)
{
m_socks4_host = a;
}
void Socket::SetSocks4Port(port_t p)
{
m_socks4_port = p;
}
void Socket::SetSocks4Userid(const std::string& x)
{
m_socks4_userid = x;
}
ipaddr_t Socket::GetSocks4Host()
{
return m_socks4_host;
}
port_t Socket::GetSocks4Port()
{
return m_socks4_port;
}
const std::string& Socket::GetSocks4Userid()
{
return m_socks4_userid;
}
#endif
void Socket::SetConnectTimeout(int x)
{
m_connect_timeout = x;
}
int Socket::GetConnectTimeout()
{
return m_connect_timeout;
}
#ifdef HAVE_OPENSSL
bool Socket::IsSSL()
{
return m_b_enable_ssl;
}
void Socket::EnableSSL(bool x)
{
m_b_enable_ssl = x;
}
bool Socket::IsSSLNegotiate()
{
return m_b_ssl;
}
void Socket::SetSSLNegotiate(bool x)
{
m_b_ssl = x;
}
bool Socket::IsSSLServer()
{
return m_b_ssl_server;
}
void Socket::SetSSLServer(bool x)
{
m_b_ssl_server = x;
}
#endif
void Socket::DisableRead(bool x)
{
m_b_disable_read = x;
}
bool Socket::IsDisableRead()
{
return m_b_disable_read;
}
void Socket::SetRetryClientConnect(bool x)
{
Handler().AddList(m_socket, LIST_RETRY, x);
m_b_retry_connect = x;
}
bool Socket::RetryClientConnect()
{
return m_b_retry_connect;
}
void Socket::SendBuf(const char *,size_t,int)
{
}
void Socket::Send(const std::string&,int)
{
}
void Socket::SetConnected(bool x)
{
m_connected = x;
}
bool Socket::IsConnected()
{
return m_connected;
}
void Socket::SetFlushBeforeClose(bool x)
{
m_flush_before_close = x;
}
bool Socket::GetFlushBeforeClose()
{
return m_flush_before_close;
}
#ifdef HAVE_OPENSSL
void Socket::OnSSLConnectFailed()
{
}
void Socket::OnSSLAcceptFailed()
{
}
#endif
int Socket::GetConnectionRetry()
{
return m_connection_retry;
}
void Socket::SetConnectionRetry(int x)
{
m_connection_retry = x;
}
int Socket::GetConnectionRetries()
{
return m_retries;
}
void Socket::IncreaseConnectionRetries()
{
m_retries++;
}
void Socket::ResetConnectionRetries()
{
m_retries = 0;
}
#ifdef ENABLE_RECONNECT
void Socket::OnDisconnect()
{
}
#endif
void Socket::SetErasedByHandler(bool x)
{
m_b_erased_by_handler = x;
}
bool Socket::ErasedByHandler()
{
return m_b_erased_by_handler;
}
#ifdef ENABLE_DETACH
void Socket::SetSlaveHandler(ISocketHandler *p)
{
m_slave_handler = p;
}
#endif
time_t Socket::TimeSinceClose()
{
return time(NULL) - m_tClose;
}
void Socket::SetShutdown(int x)
{
m_shutdown = x;
}
int Socket::GetShutdown()
{
return m_shutdown;
}
void Socket::SetClientRemoteAddress(SocketAddress& ad)
{
if (!ad.IsValid())
{
Handler().LogError(this, "SetClientRemoteAddress", 0, "remote address not valid", LOG_LEVEL_ERROR);
}
m_client_remote_address = ad.GetCopy();
}
std::auto_ptr<SocketAddress> Socket::GetClientRemoteAddress()
{
if (!m_client_remote_address.get())
{
Handler().LogError(this, "GetClientRemoteAddress", 0, "remote address not yet set", LOG_LEVEL_ERROR);
}
return std::auto_ptr<SocketAddress>(m_client_remote_address -> GetCopy());
}
uint64_t Socket::GetBytesSent(bool)
{
return 0;
}
uint64_t Socket::GetBytesReceived(bool)
{
return 0;
}
unsigned long int Socket::Random()
{
return m_prng.next();
}
Socket *Socket::Create()
{
return NULL;
}
bool Socket::OnConnectRetry()
{
return true;
}
#ifdef ENABLE_RECONNECT
void Socket::OnReconnect()
{
}
#endif
time_t Socket::Uptime()
{
return time(NULL) - m_tCreate;
}
#ifdef ENABLE_IPV6
void Socket::SetIpv6(bool x)
{
m_ipv6 = x;
}
bool Socket::IsIpv6()
{
return m_ipv6;
}
#endif
void Socket::SetCallOnConnect(bool x)
{
Handler().AddList(m_socket, LIST_CALLONCONNECT, x);
m_call_on_connect = x;
}
bool Socket::CallOnConnect()
{
return m_call_on_connect;
}
void Socket::SetReuse(bool x)
{
m_opt_reuse = x;
}
void Socket::SetKeepalive(bool x)
{
m_opt_keepalive = x;
}
void Socket::SetConnectTimeout(int x)
{
m_connect_timeout = x;
}
int Socket::GetConnectTimeout()
{
return m_connect_timeout;
}
void Socket::DisableRead(bool x)
{
m_b_disable_read = x;
}
bool Socket::IsDisableRead()
{
return m_b_disable_read;
}
void Socket::SetRetryClientConnect(bool x)
{
Handler().AddList(m_socket, LIST_RETRY, x);
m_b_retry_connect = x;
}
bool Socket::RetryClientConnect()
{
return m_b_retry_connect;
}
void Socket::SendBuf(const char *,size_t,int)
{
}
void Socket::Send(const std::string&,int)
{
}
void Socket::SetConnected(bool x)
{
m_connected = x;
}
bool Socket::IsConnected()
{
return m_connected;
}
void Socket::SetFlushBeforeClose(bool x)
{
m_flush_before_close = x;
}
bool Socket::GetFlushBeforeClose()
{
return m_flush_before_close;
}
int Socket::GetConnectionRetry()
{
return m_connection_retry;
}
void Socket::SetConnectionRetry(int x)
{
m_connection_retry = x;
}
int Socket::GetConnectionRetries()
{
return m_retries;
}
void Socket::IncreaseConnectionRetries()
{
m_retries++;
}
void Socket::ResetConnectionRetries()
{
m_retries = 0;
}
#ifdef ENABLE_RECONNECT
void Socket::OnDisconnect()
{
}
#endif
void Socket::SetErasedByHandler(bool x)
{
m_b_erased_by_handler = x;
}
bool Socket::ErasedByHandler()
{
return m_b_erased_by_handler;
}
time_t Socket::TimeSinceClose()
{
return time(NULL) - m_tClose;
}
void Socket::SetShutdown(int x)
{
m_shutdown = x;
}
int Socket::GetShutdown()
{
return m_shutdown;
}
void Socket::SetClientRemoteAddress(SocketAddress& ad)
{
if (!ad.IsValid())
{
Handler().LogError(this, "SetClientRemoteAddress", 0, "remote address not valid", LOG_LEVEL_ERROR);
}
m_client_remote_address = ad.GetCopy();
}
std::auto_ptr<SocketAddress> Socket::GetClientRemoteAddress()
{
if (!m_client_remote_address.get())
{
Handler().LogError(this, "GetClientRemoteAddress", 0, "remote address not yet set", LOG_LEVEL_ERROR);
}
return std::auto_ptr<SocketAddress>(m_client_remote_address -> GetCopy());
}
uint64_t Socket::GetBytesSent(bool)
{
return 0;
}
uint64_t Socket::GetBytesReceived(bool)
{
return 0;
}
unsigned long int Socket::Random()
{
return m_prng.next();
}
#ifdef HAVE_OPENSSL
void Socket::OnSSLConnect()
{
}
void Socket::OnSSLAccept()
{
}
bool Socket::SSLNegotiate()
{
return false;
}
bool Socket::IsSSL()
{
return m_b_enable_ssl;
}
void Socket::EnableSSL(bool x)
{
m_b_enable_ssl = x;
}
bool Socket::IsSSLNegotiate()
{
return m_b_ssl;
}
void Socket::SetSSLNegotiate(bool x)
{
m_b_ssl = x;
}
bool Socket::IsSSLServer()
{
return m_b_ssl_server;
}
void Socket::SetSSLServer(bool x)
{
m_b_ssl_server = x;
}
void Socket::OnSSLConnectFailed()
{
}
void Socket::OnSSLAcceptFailed()
{
}
#endif // HAVE_OPENSSL
#ifdef ENABLE_POOL
void Socket::CopyConnection(Socket *sock)
{
Attach( sock -> GetSocket() );
#ifdef ENABLE_IPV6
SetIpv6( sock -> IsIpv6() );
#endif
SetSocketType( sock -> GetSocketType() );
SetSocketProtocol( sock -> GetSocketProtocol() );
SetClientRemoteAddress( *sock -> GetClientRemoteAddress() );
SetRemoteAddress( *sock -> GetRemoteSocketAddress() );
}
void Socket::SetIsClient()
{
m_bClient = true;
}
void Socket::SetSocketType(int x)
{
m_socket_type = x;
}
int Socket::GetSocketType()
{
return m_socket_type;
}
void Socket::SetSocketProtocol(const std::string& x)
{
m_socket_protocol = x;
}
const std::string& Socket::GetSocketProtocol()
{
return m_socket_protocol;
}
void Socket::SetRetain()
{
if (m_bClient) m_bRetain = true;
}
bool Socket::Retain()
{
return m_bRetain;
}
void Socket::SetLost()
{
m_bLost = true;
}
bool Socket::Lost()
{
return m_bLost;
}
#endif // ENABLE_POOL
#ifdef ENABLE_SOCKS4
void Socket::OnSocks4Connect()
{
Handler().LogError(this, "OnSocks4Connect", 0, "Use with TcpSocket only");
}
void Socket::OnSocks4ConnectFailed()
{
Handler().LogError(this, "OnSocks4ConnectFailed", 0, "Use with TcpSocket only");
}
bool Socket::OnSocks4Read()
{
Handler().LogError(this, "OnSocks4Read", 0, "Use with TcpSocket only");
return true;
}
void Socket::SetSocks4Host(const std::string& host)
{
Utility::u2ip(host, m_socks4_host);
}
bool Socket::Socks4()
{
return m_bSocks4;
}
void Socket::SetSocks4(bool x)
{
m_bSocks4 = x;
}
void Socket::SetSocks4Host(ipaddr_t a)
{
m_socks4_host = a;
}
void Socket::SetSocks4Port(port_t p)
{
m_socks4_port = p;
}
void Socket::SetSocks4Userid(const std::string& x)
{
m_socks4_userid = x;
}
ipaddr_t Socket::GetSocks4Host()
{
return m_socks4_host;
}
port_t Socket::GetSocks4Port()
{
return m_socks4_port;
}
const std::string& Socket::GetSocks4Userid()
{
return m_socks4_userid;
}
#endif // ENABLE_SOCKS4
#ifdef ENABLE_DETACH
bool Socket::Detach()
{
if (!DeleteByHandler())
return false;
if (m_pThread)
return false;
if (m_detached)
return false;
SetDetach();
return true;
}
void Socket::DetachSocket()
{
SetDetached();
m_pThread = new SocketThread(this);
m_pThread -> SetRelease(true);
}
void Socket::OnDetached()
{
}
void Socket::SetDetach(bool x)
{
Handler().AddList(m_socket, LIST_DETACH, x);
m_detach = x;
}
bool Socket::IsDetach()
{
return m_detach;
}
void Socket::SetDetached(bool x)
{
m_detached = x;
}
const bool Socket::IsDetached() const
{
return m_detached;
}
void Socket::SetSlaveHandler(ISocketHandler *p)
{
m_slave_handler = p;
}
Socket::SocketThread::SocketThread(Socket *p)
:Thread(false)
,m_socket(p)
{
// Creator will release
}
Socket::SocketThread::~SocketThread()
{
if (IsRunning())
{
SetRelease(true);
SetRunning(false);
#ifdef _WIN32
Sleep(1000);
#else
sleep(1);
#endif
}
}
void Socket::SocketThread::Run()
{
SocketHandler h;
h.SetSlave();
h.Add(m_socket);
m_socket -> SetSlaveHandler(&h);
m_socket -> OnDetached();
while (h.GetCount() && IsRunning())
{
h.Select(0, 500000);
}
// m_socket now deleted oops
// yeah oops m_socket delete its socket thread, that means this
// so Socket will no longer delete its socket thread, instead we do this:
SetDeleteOnExit();
}
#endif // ENABLE_DETACH
#ifdef ENABLE_RESOLVER
int Socket::Resolve(const std::string& host,port_t port)
{
return Handler().Resolve(this, host, port);
}
#ifdef ENABLE_IPV6
int Socket::Resolve6(const std::string& host,port_t port)
{
return Handler().Resolve6(this, host, port);
}
#endif
int Socket::Resolve(ipaddr_t a)
{
return Handler().Resolve(this, a);
}
#ifdef ENABLE_IPV6
int Socket::Resolve(in6_addr& a)
{
return Handler().Resolve(this, a);
}
#endif
void Socket::OnResolved(int,ipaddr_t,port_t)
{
}
#ifdef ENABLE_IPV6
void Socket::OnResolved(int,in6_addr&,port_t)
{
}
#endif
void Socket::OnReverseResolved(int,const std::string&)
{
}
void Socket::OnResolveFailed(int)
{
}
#endif // ENABLE_RESOLVER

Socket.h

/usr/src/Sockets-2.1.3/Socket.h 2007-04-29 10:41:32.0, 0200/usr/src/Sockets-2.1.4/Socket.h 2007-05-10 13:51:25.0, 0200
Line 28 in Socket.hLine 28 in Socket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETBASE_H
#define _SOCKETBASE_H
#include "sockets-config.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Socket_H
#define _SOCKETS_Socket_H
#include "sockets-config.h"
Line 44 in Socket.hLine 44 in Socket.h
#include "SocketAddress.h"
#include "RandomNumber.h"
#include "Thread.h"
Line 52 in Socket.hLine 53 in Socket.h
class ISocketHandler;
class SocketThread;
class SocketAddress;
class ISocketHandler;
class SocketAddress;
class IFile;
Line 62 in Socket.hLine 63 in Socket.h
{
friend class ISocketHandler;
protected:
/** Detached socket run thread.
\ingroup internal */
#ifdef ENABLE_DETACH
class SocketThread : public Thread
{
public:
SocketThread(Socket *p);
~SocketThread();
void Run();
private:
Socket *GetSocket() const { return m_socket; }
SocketThread(const SocketThread& s) : m_socket(s.GetSocket()) {}
SocketThread& operator=(const SocketThread& ) { return *this; }
Socket *m_socket;
};
#endif // ENABLE_DETACH
public:
/** "Default" constructor */
Line 450 in Socket.hLine 471 in Socket.h
#endif // ENABLE_DETACH
void SetTrafficMonitor(IFile *p) { m_traffic_monitor = p; }
protected:
Socket(const Socket& ); ///< do not allow use of copy constructor
RandomNumber m_prng; ///< Random number generator
IFile *GetTrafficMonitor() { return m_traffic_monitor; }
private:
Line 492 in Socket.hLine 516 in Socket.h
std::auto_ptr<SocketAddress> m_client_remote_address; ///< Address of last connect()
std::auto_ptr<SocketAddress> m_remote_address; ///< Remote end address
IFile *m_traffic_monitor;
#ifdef HAVE_OPENSSL
Line 528 in Socket.hLine 553 in Socket.h
#endif // _SOCKETBASE_H
#endif // _SOCKETS_Socket_H

SocketHandler.cpp

/usr/src/Sockets-2.1.3/SocketHandler.cpp 2007-04-30 09:59:16.0, 0200/usr/src/Sockets-2.1.4/SocketHandler.cpp 2007-05-10 14:17:44.0, 0200
Line 37 in SocketHandler.cppLine 37 in SocketHandler.cpp
#include "SocketHandler.h"
#include "UdpSocket.h"
#include "PoolSocket.h"
#include "ResolvSocket.h"
#include "ResolvServer.h"
Line 51 in SocketHandler.cppLine 50 in SocketHandler.cpp
#ifdef _DEBUG
#define DEB(x) x
#else
#define DEB(x)
#ifdef _DEBUG
#define DEB(x) x; fflush(stderr);
#else
#define DEB(x)
Line 117 in SocketHandler.cppLine 116 in SocketHandler.cpp
while (m_sockets.size())
{
socket_m::iterator it = m_sockets.begin();
Socket *p = it -> second;
if (p)
{
p -> Close();
// p -> OnDelete(); // hey, I turn this back on. what's the worst that could happen??!!
// MinionSocket breaks, calling MinderHandler methods in OnDelete -
// MinderHandler is already gone when that happens...
m_sockets.erase(it);
// only delete socket when controlled
// ie master sockethandler can delete non-detached sockets
while (m_sockets.size())
{
DEB( fprintf(stderr, "Emptying sockets list in SocketHandler destructor, %d instances\n", m_sockets.size());)
socket_m::iterator it = m_sockets.begin();
Socket *p = it -> second;
if (p)
{
DEB( fprintf(stderr, " fd %d\n", p -> GetSocket());)
p -> Close();
DEB( fprintf(stderr, " fd closed %d\n", p -> GetSocket());)
// p -> OnDelete(); // hey, I turn this back on. what's the worst that could happen??!!
// MinionSocket breaks, calling MinderHandler methods in OnDelete -
// MinderHandler is already gone when that happens...
// only delete socket when controlled
// ie master sockethandler can delete non-detached sockets
Line 138 in SocketHandler.cppLine 140 in SocketHandler.cpp
delete p;
}
m_sockets.erase(it);
}
else
Line 143 in SocketHandler.cppLine 146 in SocketHandler.cpp
m_sockets.erase(it);
}
DEB( fprintf(stderr, "next\n");)
}
DEB( fprintf(stderr, "/Emptying sockets list in SocketHandler destructor, %d instances\n", m_sockets.size());)
}
#ifdef ENABLE_RESOLVER
Line 169 in SocketHandler.cppLine 174 in SocketHandler.cpp
return;
}
for (socket_m::iterator it = m_add.begin(); it != m_add.end(); it++)
{
if (it -> first == p -> GetSocket())
{
LogError(p, "Add", (int)p -> GetSocket(), "Attempt to add socket already in add queue", LOG_LEVEL_FATAL);
return;
}
if (m_add.find(p -> GetSocket()) != m_add.end())
{
LogError(p, "Add", (int)p -> GetSocket(), "Attempt to add socket already in add queue", LOG_LEVEL_FATAL);
Line 177 in SocketHandler.cppLine 180 in SocketHandler.cpp
return;
}
}
m_add[p -> GetSocket()] = p;
}
Line 263 in SocketHandler.cppLine 265 in SocketHandler.cpp
int SocketHandler::Select(struct timeval *tsel)
{
while (m_add.size())
{
if (m_sockets.size() >= FD_SETSIZE)
int SocketHandler::Select(struct timeval *tsel)
{
size_t ignore = 0;
while (m_add.size() > ignore)
{
if (m_sockets.size() >= FD_SETSIZE)
Line 273 in SocketHandler.cppLine 276 in SocketHandler.cpp
SOCKET s = it -> first;
Socket *p = it -> second;
DEB(fprintf(stderr, "Trying to add fd %d\n", s);)
//
{
bool dup = false;
for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++)
{
if (it -> first == p -> GetSocket())
{
LogError(p, "Add", (int)p -> GetSocket(), "Attempt to add socket already in controlled queue", LOG_LEVEL_FATAL);
m_delete.push_back(p);
m_add.erase(it);
dup = true;
break;
}
}
if (dup)
{
continue;
}
}
if (!p -> CloseAndDelete())
{
SOCKET s = it -> first;
Socket *p = it -> second;
DEB(fprintf(stderr, "Trying to add fd %d, m_add.size() %d, ignore %d\n", s, m_add.size(), ignore);)
//
if (m_sockets.find(p -> GetSocket()) != m_sockets.end())
{
LogError(p, "Add", (int)p -> GetSocket(), "Attempt to add socket already in controlled queue", LOG_LEVEL_FATAL);
// %! it's a dup, don't add to delete queue, just ignore it
// m_delete.push_back(p);
// m_add.erase(it);
ignore++;
continue;
}
if (!p -> CloseAndDelete())
{
Line 356 in SocketHandler.cppLine 350 in SocketHandler.cpp
if (n == -1)
{
if (Errno != m_preverror || m_errcnt++ % 10000 == 0)
{
LogError(NULL, "select", Errno, StrError(Errno));
m_preverror = Errno;
}
/// \todo rebuild fd_set's from active sockets list (m_sockets) here
#ifdef _WIN32
DEB(
int errcode = Errno;
if (errcode != m_preverror)
{
fprintf(stderr, " select() errcode = %d\n",errcode);
m_preverror = errcode;
for (size_t i = 0; i <= m_maxsock; i++)
{
if (FD_ISSET(i, &m_rfds))
fprintf(stderr, "%4d: Read\n",i);
if (FD_ISSET(i, &m_wfds))
fprintf(stderr, "%4d: Write\n",i);
if (FD_ISSET(i, &m_efds))
fprintf(stderr, "%4d: Exception\n",i);
}
}
// exit(-1); /// \todo remove....
) // DEB
#endif
}
else
if (n == -1)
{
/*
EBADF An invalid file descriptor was given in one of the sets.
EINTR A non blocked signal was caught.
EINVAL n is negative. Or struct timeval contains bad time values (<0).
ENOMEM select was unable to allocate memory for internal tables.
*/
if (Errno != m_preverror || m_errcnt++ % 10000 == 0)
{
LogError(NULL, "select", Errno, StrError(Errno));
DEB( fprintf(stderr, "m_maxsock: %d\n", m_maxsock);
fprintf(stderr, "%s\n", Errno == EINVAL ? "EINVAL" :
Errno == EINTR ? "EINTR" :
Errno == EBADF ? "EBADF" :
Errno == ENOMEM ? "ENOMEM" : "<another>");
// test bad fd
for (SOCKET i = 0; i <= m_maxsock; i++)
{
bool t = false;
FD_ZERO(&rfds);
FD_ZERO(&wfds);
FD_ZERO(&efds);
if (FD_ISSET(i, &m_rfds))
{
FD_SET(i, &rfds);
t = true;
}
if (FD_ISSET(i, &m_wfds))
{
FD_SET(i, &wfds);
t = true;
}
if (FD_ISSET(i, &m_efds))
{
FD_SET(i, &efds);
t = true;
}
if (t && m_sockets.find(i) == m_sockets.end())
{
fprintf(stderr, "Bad fd in fd_set: %d\n", i);
}
}
) // DEB
m_preverror = Errno;
}
/// \todo rebuild fd_set's from active sockets list (m_sockets) here
}
else
Line 643 in SocketHandler.cppLine 655 in SocketHandler.cpp
SOCKET nn = *it; //(*it3).first;
p -> SetRetryClientConnect(false);
p -> Close(); // removes from m_fds_retry
/*
#ifdef IPPROTO_IPV6
if (p -> IsIpv6())
{
tcp -> Open(p -> GetClientRemoteAddr6(), p -> GetClientRemotePort());
}
else
#endif
{
tcp -> Open(p -> GetClientRemoteAddr(), p -> GetClientRemotePort());
}
*/
std::auto_ptr<SocketAddress> ad = p -> GetClientRemoteAddress();
if (ad.get())
SOCKET nn = *it; //(*it3).first;
p -> SetRetryClientConnect(false);
DEB( fprintf(stderr, "Close() before retry client connect\n");)
p -> Close(); // removes from m_fds_retry
std::auto_ptr<SocketAddress> ad = p -> GetClientRemoteAddress();
if (ad.get())
Line 735 in SocketHandler.cppLine 736 in SocketHandler.cpp
tcp -> SetIsReconnect();
p -> SetConnected(false);
p -> Close(); // dispose of old file descriptor (Open creates a new)
p -> OnDisconnect();
/*
#ifdef IPPROTO_IPV6
if (p -> IsIpv6())
{
tcp -> Open(p -> GetClientRemoteAddr6(), p -> GetClientRemotePort());
}
else
#endif
{
tcp -> Open(p -> GetClientRemoteAddr(), p -> GetClientRemotePort());
}
*/
std::auto_ptr<SocketAddress> ad = p -> GetClientRemoteAddress();
if (ad.get())
tcp -> SetIsReconnect();
p -> SetConnected(false);
DEB( fprintf(stderr, "Close() before reconnect\n");)
p -> Close(); // dispose of old file descriptor (Open creates a new)
p -> OnDisconnect();
std::auto_ptr<SocketAddress> ad = p -> GetClientRemoteAddress();
if (ad.get())
Line 784 in SocketHandler.cppLine 774 in SocketHandler.cpp
{
Set(p -> GetSocket(),false,false,false);
DEB( fprintf(stderr, "Close() before OnDelete\n");)
p -> Close();
}
Line 827 in SocketHandler.cppLine 818 in SocketHandler.cpp
}
{
for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++)
{
if (it -> first == nn)
{
Socket *p = it -> second;
}
{
socket_m::iterator it = m_sockets.find(nn);
if (it != m_sockets.end())
{
Socket *p = it -> second;
Line 848 in SocketHandler.cppLine 838 in SocketHandler.cpp
}
m_sockets.erase(it);
break;
}
}
}
Line 1080 in SocketHandler.cppLine 1068 in SocketHandler.cpp
#ifdef ENABLE_POOL
PoolSocket *SocketHandler::FindConnection(int type,const std::string& protocol,SocketAddress& ad)
{
for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end() && m_sockets.size(); it++)
#ifdef ENABLE_POOL
ISocketHandler::PoolSocket *SocketHandler::FindConnection(int type,const std::string& protocol,SocketAddress& ad)
{
for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end() && m_sockets.size(); it++)
Line 1246 in SocketHandler.cppLine 1234 in SocketHandler.cpp
}
}
DEB( fprintf(stderr, "/AddList\n");)
}

SocketHandler.h

/usr/src/Sockets-2.1.3/SocketHandler.h 2007-04-29 10:29:39.0, 0200/usr/src/Sockets-2.1.4/SocketHandler.h 2007-05-10 15:05:44.0, 0200
Line 28 in SocketHandler.hLine 28 in SocketHandler.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETHANDLER_H
#define _SOCKETHANDLER_H
#include <map>
#include <list>
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_SocketHandler_H
#define _SOCKETS_SocketHandler_H
#include "sockets-config.h"
#include <map>
#include <list>
Line 45 in SocketHandler.hLine 46 in SocketHandler.h
class Socket;
#ifdef ENABLE_POOL
class PoolSocket;
#endif
#ifdef ENABLE_RESOLVER
class ResolvServer;
Line 104 in SocketHandler.hLine 102 in SocketHandler.h
#ifdef ENABLE_POOL
/** Find available open connection (used by connection pool). */
PoolSocket *FindConnection(int type,const std::string& protocol,SocketAddress&);
/** Enable connection pool (by default disabled). */
void EnablePool(bool x = true);
#ifdef ENABLE_POOL
/** Find available open connection (used by connection pool). */
ISocketHandler::PoolSocket *FindConnection(int type,const std::string& protocol,SocketAddress&);
/** Enable connection pool (by default disabled). */
void EnablePool(bool x = true);
Line 210 in SocketHandler.hLine 208 in SocketHandler.h
#endif
#endif // _SOCKETHANDLER_H
#endif
#endif // _SOCKETS_SocketHandler_H

socket_include.h

/usr/src/Sockets-2.1.3/socket_include.h 2007-04-30 09:02:38.0, 0200/usr/src/Sockets-2.1.4/socket_include.h 2007-05-10 13:47:40.0, 0200
Line 28 in socket_include.hLine 28 in socket_include.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKET_INCLUDE_H
#define _SOCKET_INCLUDE_H
#include "sockets-config.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_socket_include_H
#define _SOCKETS_socket_include_H
#include "sockets-config.h"
Line 271 in socket_include.hLine 271 in socket_include.h
#endif // _SOCKET_INCLUDE_H
#endif // _SOCKETS_socket_include_H

SSLInitializer.cpp

/usr/src/Sockets-2.1.3/SSLInitializer.cpp 2007-04-30 09:56:04.0, 0200/usr/src/Sockets-2.1.4/SSLInitializer.cpp 2007-05-09 22:39:10.0, 0200
Line 21 in SSLInitializer.cppLine 21 in SSLInitializer.cpp
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef _WIN32
#pragma warning(disable:4786)
#endif
#include "SSLInitializer.h"
#ifdef HAVE_OPENSSL

SSLInitializer.h

/usr/src/Sockets-2.1.3/SSLInitializer.h 2007-04-30 09:54:58.0, 0200/usr/src/Sockets-2.1.4/SSLInitializer.h 2007-05-10 13:44:54.0, 0200
Line 21 in SSLInitializer.hLine 21 in SSLInitializer.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SSLINITIALIZER_H
#define _SSLINITIALIZER_H
#include "sockets-config.h"
#ifdef HAVE_OPENSSL
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __SOCKETS_SSLInitializer_H
#define __SOCKETS_SSLInitializer_H
#include "sockets-config.h"
#ifdef HAVE_OPENSSL
Line 73 in SSLInitializer.hLine 73 in SSLInitializer.h
#endif
#endif // HAVE_OPENSSL
#endif // _SSLINITIALIZER_H
#endif
#endif // HAVE_OPENSSL
#endif // __SOCKETS_SSLInitializer_H

StdLog.h

/usr/src/Sockets-2.1.3/StdLog.h 2007-04-15 07:15:03.0, 0200/usr/src/Sockets-2.1.4/StdLog.h 2007-05-10 15:05:49.0, 0200
Line 28 in StdLog.hLine 28 in StdLog.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _STDLOG_H
#define _STDLOG_H
#include <string>
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_StdLog_H
#define _SOCKETS_StdLog_H
#include "sockets-config.h"
#include <string>
Line 69 in StdLog.hLine 70 in StdLog.h
#endif
#endif // _STDLOG_H
#endif
#endif // _SOCKETS_StdLog_H

StdoutLog.h

/usr/src/Sockets-2.1.3/StdoutLog.h 2007-04-15 07:15:08.0, 0200/usr/src/Sockets-2.1.4/StdoutLog.h 2007-05-10 15:05:57.0, 0200
Line 28 in StdoutLog.hLine 28 in StdoutLog.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _STDOUTLOG_H
#define _STDOUTLOG_H
#include "StdLog.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_StdoutLog_H
#define _SOCKETS_StdoutLog_H
#include "sockets-config.h"
#include "StdLog.h"
Line 53 in StdoutLog.hLine 54 in StdoutLog.h
#endif
#endif // _STDOUTLOG_H
#endif
#endif // _SOCKETS_StdoutLog_H

TcpSocket.cpp

/usr/src/Sockets-2.1.3/TcpSocket.cpp 2007-04-30 09:57:11.0, 0200/usr/src/Sockets-2.1.4/TcpSocket.cpp 2007-05-10 13:23:57.0, 0200
Line 44 in TcpSocket.cppLine 44 in TcpSocket.cpp
#include "TcpSocket.h"
#include "PoolSocket.h"
#include "Utility.h"
#include "Ipv4Address.h"
Line 50 in TcpSocket.cppLine 49 in TcpSocket.cpp
#include "Mutex.h"
#include "Uid.h"
#include "IFile.h"
#ifdef SOCKETS_NAMESPACE
Line 65 in TcpSocket.cppLine 65 in TcpSocket.cpp
// statics
#ifdef HAVE_OPENSSL
//BIO *TcpSocket::m_bio_err = NULL;
//bool TcpSocket::m_b_rand_file_generated = false;
//std::string TcpSocket::m_rand_file;
//long TcpSocket::m_rand_size = 1024;
SSLInitializer TcpSocket::m_ssl_init;
#endif
Line 80 in TcpSocket.cppLine 76 in TcpSocket.cpp
,ibuf(*this, TCP_BUFSIZE_READ)
,obuf(*this, 32768)
,m_line("")
#ifdef SOCKETS_DYNAMIC_TEMP
,m_buf(new char[TCP_BUFSIZE_READ + 1])
#endif
#ifdef ENABLE_SOCKS4
,m_socks4_state(0)
,ibuf(*this, TCP_BUFSIZE_READ)
,obuf(*this, 32768)
,m_b_input_buffer_disabled(false)
,m_bytes_sent(0)
,m_bytes_received(0)
,m_skip_c(false)
#ifdef SOCKETS_DYNAMIC_TEMP
,m_buf(new char[TCP_BUFSIZE_READ + 1])
#endif
#ifdef HAVE_OPENSSL
,m_ssl_ctx(NULL)
,m_ssl(NULL)
,m_sbio(NULL)
#endif
#ifdef ENABLE_SOCKS4
,m_socks4_state(0)
Line 90 in TcpSocket.cppLine 94 in TcpSocket.cpp
,m_resolver_id(0)
#endif
#ifdef HAVE_OPENSSL
,m_ssl_ctx(NULL)
,m_ssl(NULL)
,m_sbio(NULL)
#endif
#ifdef ENABLE_RECONNECT
,m_b_reconnect(false)
,m_b_is_reconnect(false)
#endif
,m_b_input_buffer_disabled(false)
,m_bytes_sent(0)
,m_bytes_received(0)
,m_skip_c(false)
{
/*
#ifdef HAVE_OPENSSL
if (!m_b_rand_file_generated)
{
m_b_rand_file_generated = true;
char *randfile = getenv("RANDFILE");
char *home = getenv("HOME");
if (!randfile && !home)
{
char *homepath = getenv("HOMEPATH");
if (homepath)
{
Utility::SetEnv("HOME", homepath);
}
}
char path[512];
*path = 0;
RAND_file_name(path, 512);
if (*path)
{
m_rand_file = path;
m_rand_size = 1024;
RAND_write_file(path);
}
else
{
Handler().LogError(this, "TcpSocket constructor", 0, "No random file generated", LOG_LEVEL_ERROR);
}
}
#endif // HAVE_OPENSSL
*/
}
#ifdef _WIN32
Line 147 in TcpSocket.cppLine 111 in TcpSocket.cpp
,ibuf(*this, isize)
,obuf(*this, osize)
,m_line("")
#ifdef SOCKETS_DYNAMIC_TEMP
,m_buf(new char[TCP_BUFSIZE_READ + 1])
#endif
#ifdef ENABLE_SOCKS4
,m_socks4_state(0)
,ibuf(*this, isize)
,obuf(*this, osize)
,m_b_input_buffer_disabled(false)
,m_bytes_sent(0)
,m_bytes_received(0)
,m_skip_c(false)
#ifdef SOCKETS_DYNAMIC_TEMP
,m_buf(new char[TCP_BUFSIZE_READ + 1])
#endif
#ifdef HAVE_OPENSSL
,m_ssl_ctx(NULL)
,m_ssl(NULL)
,m_sbio(NULL)
#endif
#ifdef ENABLE_SOCKS4
,m_socks4_state(0)
Line 157 in TcpSocket.cppLine 129 in TcpSocket.cpp
,m_resolver_id(0)
#endif
#ifdef HAVE_OPENSSL
,m_ssl_ctx(NULL)
,m_ssl(NULL)
,m_sbio(NULL)
#endif
#ifdef ENABLE_RECONNECT
,m_b_reconnect(false)
,m_b_is_reconnect(false)
#endif
,m_b_input_buffer_disabled(false)
,m_bytes_sent(0)
,m_bytes_received(0)
,m_skip_c(false)
{
/*
#ifdef HAVE_OPENSSL
if (!m_b_rand_file_generated)
{
m_b_rand_file_generated = true;
char *randfile = getenv("RANDFILE");
char *home = getenv("HOME");
if (!randfile && !home)
{
char *homepath = getenv("HOMEPATH");
if (homepath)
{
Utility::SetEnv("HOME", homepath);
}
}
char path[512];
*path = 0;
RAND_file_name(path, 512);
if (*path)
{
m_rand_file = path;
RAND_write_file(path);
}
else
{
Handler().LogError(this, "TcpSocket constructor", 0, "No random file generated", LOG_LEVEL_ERROR);
}
}
#endif // HAVE_OPENSSL
*/
}
#ifdef _WIN32
Line 228 in TcpSocket.cppLine 161 in TcpSocket.cpp
SSL_free(m_ssl);
}
// ssl context is now global (sort of)
/*
if (m_ssl_ctx)
{
SSL_CTX_free(m_ssl_ctx);
}
*/
#endif
}
Line 287 in TcpSocket.cppLine 213 in TcpSocket.cpp
if (Handler().PoolEnabled())
{
PoolSocket *pools = Handler().FindConnection(SOCK_STREAM, "tcp", ad);
if (pools)
{
if (Handler().PoolEnabled())
{
ISocketHandler::PoolSocket *pools = Handler().FindConnection(SOCK_STREAM, "tcp", ad);
if (pools)
{
Line 351 in TcpSocket.cppLine 277 in TcpSocket.cpp
#endif
{
// Handler().LogError(this, "connect: connection pending", Errno, StrError(Errno), LOG_LEVEL_INFO);
Attach(s);
SetConnecting( true ); // this flag will control fd_set's
Line 382 in TcpSocket.cppLine 307 in TcpSocket.cpp
else
{
// Handler().LogError(this, "connect", 0, "connection established", LOG_LEVEL_INFO);
Attach(s);
SetCallOnConnect(); // ISocketHandler must call OnConnect
// Handler().LogError(this, "SetCallOnConnect", n, "connect() returns != -1", LOG_LEVEL_INFO);
}
Line 400 in TcpSocket.cppLine 323 in TcpSocket.cpp
if (IsIpv6())
{
in6_addr a;
/// \todo enable ipv6 async resolver
if (!Utility::u2ip(host, a))
{
if (IsIpv6())
{
#ifdef ENABLE_RESOLVER
if (!Handler().ResolvedEnabled() || Utility::isipv4(host) )
{
#endif
in6_addr a;
if (!Utility::u2ip(host, a))
{
Line 410 in TcpSocket.cppLine 336 in TcpSocket.cpp
Ipv6Address local;
return Open(ad, local);
#ifdef ENABLE_RESOLVER
}
m_resolver_id = Resolve6(host, port);
return true;
#endif
}
#endif
Line 544 in TcpSocket.cppLine 475 in TcpSocket.cpp
SetLost();
#endif
SetShutdown(SHUT_WR);
return;
}
Line 550 in TcpSocket.cppLine 482 in TcpSocket.cpp
{
m_bytes_received += n;
// OnRawData(buf,n);
if (!m_b_input_buffer_disabled && !ibuf.Write(buf,n))
{
// overflow
Handler().LogError(this, "OnRead(ssl)", 0, "ibuf overflow", LOG_LEVEL_WARNING);
}
{
m_bytes_received += n;
if (GetTrafficMonitor())
{
GetTrafficMonitor() -> fwrite(buf, 1, n);
}
if (!m_b_input_buffer_disabled && !ibuf.Write(buf,n))
{
Handler().LogError(this, "OnRead(ssl)", 0, "ibuf overflow", LOG_LEVEL_WARNING);
}
Line 579 in TcpSocket.cppLine 513 in TcpSocket.cpp
if (!n)
{
// Handler().LogError(this, "read", 0, "read returns 0", LOG_LEVEL_FATAL);
SetCloseAndDelete(true);
SetFlushBeforeClose(false);
Line 585 in TcpSocket.cppLine 518 in TcpSocket.cpp
SetLost();
#endif
SetShutdown(SHUT_WR);
return;
}
Line 591 in TcpSocket.cppLine 525 in TcpSocket.cpp
{
m_bytes_received += n;
// OnRawData(buf,n);
if (!m_b_input_buffer_disabled && !ibuf.Write(buf,n))
{
// overflow
Handler().LogError(this, "OnRead", 0, "ibuf overflow", LOG_LEVEL_WARNING);
}
{
m_bytes_received += n;
if (GetTrafficMonitor())
{
GetTrafficMonitor() -> fwrite(buf, 1, n);
}
if (!m_b_input_buffer_disabled && !ibuf.Write(buf,n))
{
Handler().LogError(this, "OnRead", 0, "ibuf overflow", LOG_LEVEL_WARNING);
}
Line 677 in TcpSocket.cppLine 613 in TcpSocket.cpp
}
#endif
/*
else
if (LineProtocol())
{
size_t x = 0;
size_t n = ibuf.GetLength();
#ifdef SOCKETS_DYNAMIC_TEMP
char *tmp = m_buf;
#else
char tmp[TCP_BUFSIZE_READ + 1];
#endif
n = (n >= TCP_BUFSIZE_READ) ? TCP_BUFSIZE_READ : n;
ibuf.Read(tmp,n);
tmp[n] = 0;
for (size_t i = 0; i < n; i++)
{
while (tmp[i] == 13 || tmp[i] == 10)
{
char c = tmp[i];
tmp[i] = 0;
if (tmp[x])
{
m_line += (tmp + x);
}
OnLine( m_line );
i++;
if (i < n && (tmp[i] == 13 || tmp[i] == 10) && tmp[i] != c)
{
i++;
}
x = i;
m_line = "";
}
}
if (tmp[x])
{
m_line += (tmp + x);
}
}
*/
}
Line 785 in TcpSocket.cppLine 680 in TcpSocket.cpp
{
m_bytes_sent += n;
if (GetTrafficMonitor())
{
GetTrafficMonitor() -> fwrite(obuf.GetStart(), 1, n);
}
obuf.Remove(n);
// move data from m_mes to immediate output buffer
Line 852 in TcpSocket.cppLine 751 in TcpSocket.cpp
{
m_bytes_sent += n;
if (GetTrafficMonitor())
{
GetTrafficMonitor() -> fwrite(obuf.GetStart(), 1, n);
}
obuf.Remove(n);
// move data from m_mes to immediate output buffer
Line 948 in TcpSocket.cppLine 851 in TcpSocket.cpp
/*
void TcpSocket::ReadLine()
{
if (ibuf.GetLength())
{
size_t x = 0;
size_t n = ibuf.GetLength();
#ifdef SOCKETS_DYNAMIC_TEMP
char *tmp = m_buf;
#else
char tmp[TCP_BUFSIZE_READ + 1];
#endif
n = (n >= TCP_BUFSIZE_READ) ? TCP_BUFSIZE_READ : n;
ibuf.Read(tmp,n);
tmp[n] = 0;
for (size_t i = 0; i < n; i++)
{
while (tmp[i] == 13 || tmp[i] == 10)
{
char c = tmp[i];
tmp[i] = 0;
if (tmp[x])
{
m_line += (tmp + x);
}
OnLine( m_line );
i++;
if (i < n && (tmp[i] == 13 || tmp[i] == 10) && tmp[i] != c)
{
i++;
}
x = i;
m_line = "";
}
}
if (tmp[x])
{
m_line += (tmp + x);
}
}
}
*/
#ifdef _WIN32
#pragma warning(disable:4355)
Line 1165 in TcpSocket.cppLine 1023 in TcpSocket.cpp
}
SSL_set_bio(m_ssl, m_sbio, m_sbio);
if (!SSLNegotiate())
{
SetSSLNegotiate();
}
SSL_set_bio(m_ssl, m_sbio, m_sbio);
// if (!SSLNegotiate())
{
SetSSLNegotiate();
Line 1208 in TcpSocket.cppLine 1066 in TcpSocket.cpp
}
SSL_set_bio(m_ssl, m_sbio, m_sbio);
if (!SSLNegotiate())
{
SetSSLNegotiate();
}
SSL_set_bio(m_ssl, m_sbio, m_sbio);
// if (!SSLNegotiate())
{
SetSSLNegotiate();
Line 1241 in TcpSocket.cppLine 1099 in TcpSocket.cpp
#endif
{
// Handler().LogError(this, "Calling OnConnect", 0, "SSLNegotiate", LOG_LEVEL_INFO);
OnConnect();
}
// OnConnect();
Handler().LogError(this, "SSLNegotiate/SSL_connect", 0, "Connection established", LOG_LEVEL_INFO);
return true;
Line 1317 in TcpSocket.cppLine 1173 in TcpSocket.cpp
void TcpSocket::InitSSLClient()
{
// InitializeContext();
InitializeContext("", SSLv23_method());
}
Line 1331 in TcpSocket.cppLine 1186 in TcpSocket.cpp
void TcpSocket::InitializeContext(const std::string& context, SSL_METHOD *meth_in)
{
/*
if (!m_bio_err)
{
// An error write context
m_bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
// Global system initialization
SSL_library_init();
SSL_load_error_strings();
OpenSSL_add_all_algorithms();
CRYPTO_set_locking_callback( SSL_locking_function );
CRYPTO_set_id_callback( SSL_id_function );
}
*/
/* Create our context*/
static std::map<std::string, SSL_CTX *> client_contexts;
Line 1357 in TcpSocket.cppLine 1198 in TcpSocket.cpp
m_ssl_ctx = client_contexts[context];
}
/* Load randomness */
/*
if (!m_rand_file.size() || !RAND_load_file(m_rand_file.c_str(), m_rand_size))
{
Handler().LogError(this, "TcpSocket InitializeContext", 0, "Couldn't load randomness", LOG_LEVEL_ERROR);
}
*/
}
Line 1370 in TcpSocket.cppLine 1203 in TcpSocket.cpp
void TcpSocket::InitializeContext(const std::string& context,const std::string& keyfile,const std::string& password,SSL_METHOD *meth_in)
{
/*
if (!m_bio_err)
{
// An error write context
m_bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
// Global system initialization
SSL_library_init();
SSL_load_error_strings();
OpenSSL_add_all_algorithms();
CRYPTO_set_locking_callback( SSL_locking_function );
CRYPTO_set_id_callback( SSL_id_function );
}
*/
/* Create our context*/
static std::map<std::string, SSL_CTX *> server_contexts;
Line 1415 in TcpSocket.cppLine 1234 in TcpSocket.cpp
Handler().LogError(this, "TcpSocket InitializeContext", 0, "Couldn't read private key file " + keyfile, LOG_LEVEL_FATAL);
}
/* Load randomness */
/*
if (!m_rand_file.size() || !RAND_load_file(m_rand_file.c_str(), m_rand_size))
{
Handler().LogError(this, "TcpSocket InitializeContext", 0, "Couldn't load randomness", LOG_LEVEL_ERROR);
}
*/
}
// static
int TcpSocket::SSL_password_cb(char *buf,int num,int rwflag,void *userdata)
{
Line 1439 in TcpSocket.cppLine 1249 in TcpSocket.cpp
return (int)pw.size();
}
/*
void TcpSocket::SSL_locking_function(int mode, int n, const char *file, int line)
{
static std::map<int, Mutex *> mmap;
if (mmap.find(n) == mmap.end())
{
mmap[n] = new Mutex;
}
if (mode & CRYPTO_LOCK)
{
mmap[n] -> Lock();
}
else
{
mmap[n] -> Unlock();
}
}
unsigned long TcpSocket::SSL_id_function()
{
return Utility::ThreadID();
}
*/
#endif // HAVE_OPENSSL
Line 1480 in TcpSocket.cppLine 1262 in TcpSocket.cpp
m_ssl = NULL;
}
/*
if (m_ssl_ctx)
{
SSL_CTX_free(m_ssl_ctx);
m_ssl_ctx = NULL;
}
*/
#endif
return Socket::Close();
Line 1577 in TcpSocket.cppLine 1352 in TcpSocket.cpp
return m_password;
}
/*
void TcpSocket::SetRandFile(const std::string& file,long size)
{
m_rand_file = file;
m_rand_size = size;
FILE *fil = fopen(file.c_str(), "wb");
if (fil)
{
for (long i = 0; i < size; i++)
{
long rnd = Random();
fwrite(&rnd, 1, 1, fil);
}
fclose(fil);
}
else
{
Handler().LogError(this, "TcpSocket SetRandFile", 0, "Couldn't write to random file", LOG_LEVEL_ERROR);
}
}
void TcpSocket::DeleteRandFile()
{
if (m_rand_file.size())
{
unlink(m_rand_file.c_str());
}
}
*/
#endif

TcpSocket.h

/usr/src/Sockets-2.1.3/TcpSocket.h 2007-04-30 09:25:33.0, 0200/usr/src/Sockets-2.1.4/TcpSocket.h 2007-05-10 14:38:17.0, 0200
Line 28 in TcpSocket.hLine 28 in TcpSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _TCPSOCKET_H
#define _TCPSOCKET_H
#include "sockets-config.h"
#include "Socket.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_TcpSocket_H
#define _SOCKETS_TcpSocket_H
#include "sockets-config.h"
#include "Socket.h"
Line 73 in TcpSocket.hLine 73 in TcpSocket.h
typedef std::list<MES *> ucharp_v;
public:
/** SSL Initialization, Removes ssl .rnd file */
/*
#ifdef HAVE_OPENSSL
class SSLInitializer {
public:
SSLInitializer() {
}
~SSLInitializer() {
TcpSocket::DeleteRandFile();
}
};
#endif
*/
public:
/** Constructor with standard values on input/output buffers. */
TcpSocket(ISocketHandler& );
Line 145 in TcpSocket.hLine 131 in TcpSocket.h
size_t GetOutputLength();
/** Callback used when socket is in line protocol mode.
\sa SetLineProtocol */
// void ReadLine();
/** Callback fires when a socket in line protocol has read one full line.
\param line Line read */
Line 195 in TcpSocket.hLine 178 in TcpSocket.h
#endif
#ifdef HAVE_OPENSSL
/** SSL; Get ssl password. */
const std::string& GetPassword();
/** SSL; Set random filename + size to be used. */
// void SetRandFile(const std::string& file,long size);
/** SSL; delete random file when shutting down. */
//static void DeleteRandFile();
#endif
void DisableInputBuffer(bool = true);
Line 225 in TcpSocket.hLine 199 in TcpSocket.h
/** SSL; Password callback method. */
static int SSL_password_cb(char *buf,int num,int rwflag,void *userdata);
/** SSL; mutex locking function callback. */
//static void SSL_locking_function(int mode, int n, const char *file, int line);
/** Return thread id. */
//static unsigned long SSL_id_function();
/** SSL; Get pointer to ssl context structure. */
virtual SSL_CTX *GetSslContext();
Line 235 in TcpSocket.hLine 205 in TcpSocket.h
/** ssl; still negotiating connection. */
bool SSLNegotiate();
#endif
//
CircularBuffer ibuf; ///< Circular input buffer
CircularBuffer obuf; ///< Circular output buffer
std::string m_line; ///< Current line in line protocol mode
ucharp_v m_mes; ///< overflow protection, dynamic output buffer
/** ssl; still negotiating connection. */
bool SSLNegotiate();
/** SSL; Get ssl password. */
const std::string& GetPassword();
#endif
CircularBuffer ibuf; ///< Circular input buffer
CircularBuffer obuf; ///< Circular output buffer
private:
TcpSocket& operator=(const TcpSocket& ) { return *this; }
bool m_b_input_buffer_disabled;
uint64_t m_bytes_sent;
uint64_t m_bytes_received;
bool m_skip_c; ///< Skip second char of CRLF or LFCR sequence in OnRead
char m_c; ///< First char in CRLF or LFCR sequence
std::string m_line; ///< Current line in line protocol mode
ucharp_v m_mes; ///< overflow protection, dynamic output buffer
Line 245 in TcpSocket.hLine 225 in TcpSocket.h
#endif
private:
TcpSocket& operator=(const TcpSocket& ) { return *this; }
#ifdef ENABLE_SOCKS4
int m_socks4_state; ///< socks4 support
#endif
#ifdef HAVE_OPENSSL
static SSLInitializer m_ssl_init;
SSL_CTX *m_ssl_ctx; ///< ssl context
SSL *m_ssl; ///< ssl 'socket'
BIO *m_sbio; ///< ssl bio
std::string m_password; ///< ssl password
#endif
#ifdef ENABLE_SOCKS4
int m_socks4_state; ///< socks4 support
Line 257 in TcpSocket.hLine 244 in TcpSocket.h
int m_resolver_id; ///< Resolver id (if any) for current Open call
#endif
// SSL
#ifdef HAVE_OPENSSL
SSL_CTX *m_ssl_ctx; ///< ssl context
SSL *m_ssl; ///< ssl 'socket'
BIO *m_sbio; ///< ssl bio
//static BIO *m_bio_err; ///< ssl bio err
std::string m_password; ///< ssl password
//static bool m_b_rand_file_generated; ///< rand_file is generated once
//static std::string m_rand_file;
//static long m_rand_size;
#endif
// state flags
#ifdef ENABLE_RECONNECT
bool m_b_reconnect; ///< Reconnect on lost connection flag
bool m_b_is_reconnect; ///< Trying to reconnect
#endif
#ifdef HAVE_OPENSSL
static SSLInitializer m_ssl_init;
#endif
bool m_b_input_buffer_disabled;
uint64_t m_bytes_sent;
uint64_t m_bytes_received;
bool m_skip_c; ///< Skip second char of CRLF or LFCR sequence in OnRead
char m_c; ///< First char in CRLF or LFCR sequence
};
int m_resolver_id; ///< Resolver id (if any) for current Open call
#endif
#ifdef ENABLE_RECONNECT
bool m_b_reconnect; ///< Reconnect on lost connection flag
bool m_b_is_reconnect; ///< Trying to reconnect
#endif
};
Line 288 in TcpSocket.hLine 257 in TcpSocket.h
#endif
#endif // _TCPSOCKET_H
#endif
#endif // _SOCKETS_TcpSocket_H

Thread.h

/usr/src/Sockets-2.1.3/Thread.h 2007-04-15 16:06:46.0, 0200/usr/src/Sockets-2.1.4/Thread.h 2007-05-10 15:06:05.0, 0200
Line 28 in Thread.hLine 28 in Thread.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_THREAD_H
#define _SOCKETS_THREAD_H
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Thread_H
#define _SOCKETS_Thread_H
#include "sockets-config.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
Line 96 in Thread.hLine 97 in Thread.h
#endif
#endif // _SOCKETS_THREAD_H
#endif
#endif // _SOCKETS_Thread_H

UdpSocket.h

/usr/src/Sockets-2.1.3/UdpSocket.h 2007-04-22 21:00:17.0, 0200/usr/src/Sockets-2.1.4/UdpSocket.h 2007-05-10 15:06:09.0, 0200
Line 28 in UdpSocket.hLine 28 in UdpSocket.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _UDPSOCKET_H
#define _UDPSOCKET_H
#include "Socket.h"
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_UdpSocket_H
#define _SOCKETS_UdpSocket_H
#include "sockets-config.h"
#include "Socket.h"
Line 194 in UdpSocket.hLine 195 in UdpSocket.h
#endif
#endif // _UDPSOCKET_H
#endif
#endif // _SOCKETS_UdpSocket_H

Uid.h

/usr/src/Sockets-2.1.3/Uid.h 2007-04-15 07:15:15.0, 0200/usr/src/Sockets-2.1.4/Uid.h 2007-05-10 15:06:17.0, 0200
Line 28 in Uid.hLine 28 in Uid.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _UID_H
#define _UID_H
// donerat till Tekton 2003-11-12 / AH
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Uid_H
#define _SOCKETS_Uid_H
#include "sockets-config.h"
// donerat till Tekton 2003-11-12 / AH
Line 66 in Uid.hLine 67 in Uid.h
#endif
#endif // _UID_H
#endif
#endif // _SOCKETS_Uid_H

Utility.h

/usr/src/Sockets-2.1.3/Utility.h 2007-04-29 08:22:52.0, 0200/usr/src/Sockets-2.1.4/Utility.h 2007-05-10 15:06:23.0, 0200
Line 28 in Utility.hLine 28 in Utility.h
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _UTILITY_H
#define _UTILITY_H
#include <ctype.h>
#ifdef _WIN32
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Utility_H
#define _SOCKETS_Utility_H
#include "sockets-config.h"
#include <ctype.h>
#ifdef _WIN32
Line 155 in Utility.hLine 156 in Utility.h
#endif
#endif // _UTILITY_H
#endif
#endif // _SOCKETS_Utility_H
Page, code, and content Copyright (C) 2013 by Anders Hedström