MongoDB  2.7.0
Public Member Functions | Static Public Attributes | List of all members
mongo::Socket Class Reference

thin wrapped around file descriptor and system calls todo: ssl More...

#include <sock.h>

Public Member Functions

 Socket (int sock, const SockAddr &farEnd)
 
 Socket (double so_timeout=0, logger::LogSeverity logLevel=logger::LogSeverity::Log())
 In some cases the timeout will actually be 2x this value - eg we do a partial send, then the timeout fires, then we try to send again, then the timeout fires again with no data sent, then we detect that the other side is down. More...
 
bool connect (SockAddr &farEnd)
 
void close ()
 
void send (const char *data, int len, const char *context)
 
void send (const std::vector< std::pair< char *, int > > &data, const char *context)
 
void recv (char *data, int len)
 
int unsafe_recv (char *buf, int max)
 
logger::LogSeverity getLogLevel () const
 
void setLogLevel (logger::LogSeverity ll)
 
SockAddr remoteAddr () const
 
std::string remoteString () const
 
unsigned remotePort () const
 
SockAddr localAddr () const
 
void clearCounters ()
 
long long getBytesIn () const
 
long long getBytesOut () const
 
int rawFD () const
 
void setTimeout (double secs)
 
bool isStillConnected ()
 
void setHandshakeReceived ()
 
bool isAwaitingHandshake ()
 
std::string doSSLHandshake (const char *firstBytes=NULL, int len=0)
 This function calls SSL_accept() if SSL-encrypted sockets are desired. More...
 
uint64_t getSockCreationMicroSec () const
 
void handleRecvError (int ret, int len)
 
MONGO_COMPILER_NORETURN void handleSendError (int ret, const char *context)
 

Static Public Attributes

static const int errorPollIntervalSecs
 

Detailed Description

thin wrapped around file descriptor and system calls todo: ssl

Constructor & Destructor Documentation

mongo::Socket::Socket ( double  so_timeout = 0,
logger::LogSeverity  logLevel = logger::LogSeverity::Log() 
)

In some cases the timeout will actually be 2x this value - eg we do a partial send, then the timeout fires, then we try to send again, then the timeout fires again with no data sent, then we detect that the other side is down.

Generally you don't want a timeout, you should be very prepared for errors if you set one.

Member Function Documentation

std::string mongo::Socket::doSSLHandshake ( const char *  firstBytes = NULL,
int  len = 0 
)

This function calls SSL_accept() if SSL-encrypted sockets are desired.

SSL_accept() waits until the remote host calls SSL_connect(). The return value is the subject name of any client certificate provided during the handshake.

is the first bytes received on the socket used to detect the connection SSL, is the number of bytes

This function may throw SocketException.

uint64_t mongo::Socket::getSockCreationMicroSec ( ) const
inline
Returns
the time when the socket was opened.

The documentation for this class was generated from the following files: