diff options
Diffstat (limited to 'dep/src/sockets/TcpSocket.cpp')
-rw-r--r-- | dep/src/sockets/TcpSocket.cpp | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/dep/src/sockets/TcpSocket.cpp b/dep/src/sockets/TcpSocket.cpp index c4efa05d5bf..5f067b53124 100644 --- a/dep/src/sockets/TcpSocket.cpp +++ b/dep/src/sockets/TcpSocket.cpp @@ -58,20 +58,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace SOCKETS_NAMESPACE { #endif - //#ifdef _DEBUG //#define DEB(x) x //#else #define DEB(x) //#endif - // statics #ifdef HAVE_OPENSSL SSLInitializer TcpSocket::m_ssl_init; #endif - // thanks, q #ifdef _MSC_VER #pragma warning(disable:4355) @@ -109,7 +106,6 @@ TcpSocket::TcpSocket(ISocketHandler& h) : StreamSocket(h) #pragma warning(default:4355) #endif - #ifdef _MSC_VER #pragma warning(disable:4355) #endif @@ -146,7 +142,6 @@ TcpSocket::TcpSocket(ISocketHandler& h,size_t isize,size_t osize) : StreamSocket #pragma warning(default:4355) #endif - TcpSocket::~TcpSocket() { #ifdef SOCKETS_DYNAMIC_TEMP @@ -168,7 +163,6 @@ TcpSocket::~TcpSocket() #endif } - bool TcpSocket::Open(ipaddr_t ip,port_t port,bool skip_socks) { Ipv4Address ad(ip, port); @@ -176,7 +170,6 @@ bool TcpSocket::Open(ipaddr_t ip,port_t port,bool skip_socks) return Open(ad, local, skip_socks); } - #ifdef ENABLE_IPV6 #ifdef IPPROTO_IPV6 bool TcpSocket::Open(in6_addr ip,port_t port,bool skip_socks) @@ -187,14 +180,12 @@ bool TcpSocket::Open(in6_addr ip,port_t port,bool skip_socks) #endif #endif - bool TcpSocket::Open(SocketAddress& ad,bool skip_socks) { Ipv4Address bind_ad("0.0.0.0", 0); return Open(ad, bind_ad, skip_socks); } - bool TcpSocket::Open(SocketAddress& ad,SocketAddress& bind_ad,bool skip_socks) { if (!ad.IsValid()) @@ -320,7 +311,6 @@ bool TcpSocket::Open(SocketAddress& ad,SocketAddress& bind_ad,bool skip_socks) return true; //!Connecting(); } - bool TcpSocket::Open(const std::string &host,port_t port) { #ifdef ENABLE_IPV6 @@ -369,7 +359,6 @@ bool TcpSocket::Open(const std::string &host,port_t port) #endif } - #ifdef ENABLE_RESOLVER void TcpSocket::OnResolved(int id,ipaddr_t a,port_t port) { @@ -401,7 +390,6 @@ DEB( fprintf(stderr, "TcpSocket::OnResolved id %d addr %x port %d\n", id, a, } } - #ifdef ENABLE_IPV6 void TcpSocket::OnResolved(int id,in6_addr& a,port_t port) { @@ -429,7 +417,6 @@ void TcpSocket::OnResolved(int id,in6_addr& a,port_t port) #endif #endif - void TcpSocket::OnRead() { int n = 0; @@ -542,7 +529,6 @@ DEB( fprintf(stderr, "SSL read problem, errcode = %d\n",n);) OnRead( buf, n ); } - void TcpSocket::OnRead( char *buf, size_t n ) { // unbuffered @@ -620,12 +606,10 @@ void TcpSocket::OnRead( char *buf, size_t n ) #endif } - void TcpSocket::OnWriteComplete() { } - void TcpSocket::OnWrite() { if (Connecting()) @@ -718,7 +702,6 @@ void TcpSocket::OnWrite() } } - int TcpSocket::TryWrite(const char *buf, size_t len) { int n = 0; @@ -787,7 +770,6 @@ DEB( int errnr = SSL_get_error(m_ssl, n); return n; } - void TcpSocket::Buffer(const char *buf, size_t len) { size_t ptr = 0; @@ -819,13 +801,11 @@ void TcpSocket::Buffer(const char *buf, size_t len) } } - void TcpSocket::Send(const std::string &str,int i) { SendBuf(str.c_str(),str.size(),i); } - void TcpSocket::SendBuf(const char *buf,size_t len,int) { if (!Ready() && !Connecting()) @@ -876,12 +856,10 @@ void TcpSocket::SendBuf(const char *buf,size_t len,int) } } - void TcpSocket::OnLine(const std::string& ) { } - #ifdef _MSC_VER #pragma warning(disable:4355) #endif @@ -894,7 +872,6 @@ TcpSocket::TcpSocket(const TcpSocket& s) #pragma warning(default:4355) #endif - #ifdef ENABLE_SOCKS4 void TcpSocket::OnSocks4Connect() { @@ -929,7 +906,6 @@ void TcpSocket::OnSocks4Connect() m_socks4_state = 0; } - void TcpSocket::OnSocks4ConnectFailed() { Handler().LogError(this,"OnSocks4ConnectFailed",0,"connection to socks4 server failed, trying direct connection",LOG_LEVEL_WARNING); @@ -945,7 +921,6 @@ void TcpSocket::OnSocks4ConnectFailed() } } - bool TcpSocket::OnSocks4Read() { switch (m_socks4_state) @@ -1005,7 +980,6 @@ bool TcpSocket::OnSocks4Read() } #endif - void TcpSocket::Sendf(const char *format, ...) { va_list ap; @@ -1020,7 +994,6 @@ void TcpSocket::Sendf(const char *format, ...) Send( slask ); } - #ifdef HAVE_OPENSSL void TcpSocket::OnSSLConnect() { @@ -1064,7 +1037,6 @@ DEB( fprintf(stderr, " m_sbio is NULL\n");) } } - void TcpSocket::OnSSLAccept() { SetNonblocking(true); @@ -1103,7 +1075,6 @@ DEB( fprintf(stderr, " m_sbio is NULL\n");) } } - bool TcpSocket::SSLNegotiate() { if (!IsSSLServer()) // client @@ -1200,20 +1171,17 @@ DEB( fprintf(stderr, "SSL_accept() failed - closing socket, retur return false; } - void TcpSocket::InitSSLClient() { InitializeContext("", SSLv23_method()); } - void TcpSocket::InitSSLServer() { Handler().LogError(this, "InitSSLServer", 0, "You MUST implement your own InitSSLServer method", LOG_LEVEL_FATAL); SetCloseAndDelete(); } - void TcpSocket::InitializeContext(const std::string& context, SSL_METHOD *meth_in) { /* Create our context*/ @@ -1230,7 +1198,6 @@ void TcpSocket::InitializeContext(const std::string& context, SSL_METHOD *meth_i } } - void TcpSocket::InitializeContext(const std::string& context,const std::string& keyfile,const std::string& password,SSL_METHOD *meth_in) { /* Create our context*/ @@ -1266,7 +1233,6 @@ void TcpSocket::InitializeContext(const std::string& context,const std::string& } } - void TcpSocket::InitializeContext(const std::string& context,const std::string& certfile,const std::string& keyfile,const std::string& password,SSL_METHOD *meth_in) { /* Create our context*/ @@ -1302,7 +1268,6 @@ void TcpSocket::InitializeContext(const std::string& context,const std::string& } } - int TcpSocket::SSL_password_cb(char *buf,int num,int rwflag,void *userdata) { Socket *p0 = static_cast<Socket *>(userdata); @@ -1317,7 +1282,6 @@ int TcpSocket::SSL_password_cb(char *buf,int num,int rwflag,void *userdata) } #endif // HAVE_OPENSSL - int TcpSocket::Close() { if (GetSocket() == INVALID_SOCKET) // this could happen @@ -1356,7 +1320,6 @@ int TcpSocket::Close() return Socket::Close(); } - #ifdef HAVE_OPENSSL SSL_CTX *TcpSocket::GetSslContext() { @@ -1373,7 +1336,6 @@ SSL *TcpSocket::GetSsl() } #endif - #ifdef ENABLE_RECONNECT void TcpSocket::SetReconnect(bool x) { @@ -1381,24 +1343,20 @@ void TcpSocket::SetReconnect(bool x) } #endif - void TcpSocket::OnRawData(const char *buf_in,size_t len) { } - size_t TcpSocket::GetInputLength() { return ibuf.GetLength(); } - size_t TcpSocket::GetOutputLength() { return m_output_length; } - uint64_t TcpSocket::GetBytesReceived(bool clear) { uint64_t z = m_bytes_received; @@ -1407,7 +1365,6 @@ uint64_t TcpSocket::GetBytesReceived(bool clear) return z; } - uint64_t TcpSocket::GetBytesSent(bool clear) { uint64_t z = m_bytes_sent; @@ -1416,27 +1373,23 @@ uint64_t TcpSocket::GetBytesSent(bool clear) return z; } - #ifdef ENABLE_RECONNECT bool TcpSocket::Reconnect() { return m_b_reconnect; } - void TcpSocket::SetIsReconnect(bool x) { m_b_is_reconnect = x; } - bool TcpSocket::IsReconnect() { return m_b_is_reconnect; } #endif - #ifdef HAVE_OPENSSL const std::string& TcpSocket::GetPassword() { @@ -1444,13 +1397,11 @@ const std::string& TcpSocket::GetPassword() } #endif - void TcpSocket::DisableInputBuffer(bool x) { m_b_input_buffer_disabled = x; } - void TcpSocket::OnOptions(int family,int type,int protocol,SOCKET s) { DEB( fprintf(stderr, "Socket::OnOptions()\n");) @@ -1461,14 +1412,12 @@ DEB( fprintf(stderr, "Socket::OnOptions()\n");) SetSoKeepalive(true); } - void TcpSocket::SetLineProtocol(bool x) { StreamSocket::SetLineProtocol(x); DisableInputBuffer(x); } - bool TcpSocket::SetTcpNodelay(bool x) { #ifdef TCP_NODELAY @@ -1485,7 +1434,6 @@ bool TcpSocket::SetTcpNodelay(bool x) #endif } - TcpSocket::CircularBuffer::CircularBuffer(size_t size) :buf(new char[2 * size]) ,m_max(size) @@ -1496,13 +1444,11 @@ TcpSocket::CircularBuffer::CircularBuffer(size_t size) { } - TcpSocket::CircularBuffer::~CircularBuffer() { delete[] buf; } - bool TcpSocket::CircularBuffer::Write(const char *s,size_t l) { if (m_q + l > m_max) @@ -1532,7 +1478,6 @@ bool TcpSocket::CircularBuffer::Write(const char *s,size_t l) return true; } - bool TcpSocket::CircularBuffer::Read(char *s,size_t l) { if (l > m_q) @@ -1598,31 +1543,26 @@ bool TcpSocket::CircularBuffer::Remove(size_t l) return Read(NULL, l); } - size_t TcpSocket::CircularBuffer::GetLength() { return m_q; } - const char *TcpSocket::CircularBuffer::GetStart() { return buf + m_b; } - size_t TcpSocket::CircularBuffer::GetL() { return (m_b + m_q > m_max) ? m_max - m_b : m_q; } - size_t TcpSocket::CircularBuffer::Space() { return m_max - m_q; } - unsigned long TcpSocket::CircularBuffer::ByteCounter(bool clear) { if (clear) @@ -1634,7 +1574,6 @@ unsigned long TcpSocket::CircularBuffer::ByteCounter(bool clear) return m_count; } - std::string TcpSocket::CircularBuffer::ReadString(size_t l) { char *sz = new char[l + 1]; @@ -1649,7 +1588,6 @@ std::string TcpSocket::CircularBuffer::ReadString(size_t l) return tmp; } - void TcpSocket::OnConnectTimeout() { Handler().LogError(this, "connect", -1, "connect timeout", LOG_LEVEL_FATAL); @@ -1687,7 +1625,6 @@ void TcpSocket::OnConnectTimeout() SetConnecting(false); } - #ifdef _WIN32 void TcpSocket::OnException() { @@ -1723,24 +1660,20 @@ void TcpSocket::OnException() } #endif // _WIN32 - int TcpSocket::Protocol() { return IPPROTO_TCP; } - void TcpSocket::SetTransferLimit(size_t sz) { m_transfer_limit = sz; } - void TcpSocket::OnTransferLimit() { } - #ifdef SOCKETS_NAMESPACE } #endif |