39#ifndef BLOCXX_SOCKET_HPP_INCLUDE_GUARD_
40#define BLOCXX_SOCKET_HPP_INCLUDE_GUARD_
41#include "blocxx/BLOCXX_config.h"
57#include <openssl/ssl.h>
106 {
m_impl->connect(addr); }
182 {
return m_impl->write(dataOut, dataOutLen, errorAsException); }
192 {
return m_impl->read(dataIn, dataInLen, errorAsException); }
210 {
return m_impl->waitForInput(timeout); }
228 {
return m_impl->waitForOutput(timeout); }
246 {
return m_impl->getInputStream(); }
253 {
return m_impl->getOutputStream(); }
260 {
return m_impl->getIOStream(); }
276 static void createShutDownMechanism();
282 static void shutdownAllSockets();
287 static bool gotShutDown() BLOCXX_DEPRECATED;
288 static
void deleteShutDownMechanism();
290#if defined(BLOCXX_WIN32)
291 typedef HANDLE ShutDownMechanism_t;
313 bool peerCertVerified()
const;
328#pragma warning (push)
329#pragma warning (disable: 4251)
#define BLOCXX_DECLARE_APIEXCEPTION(NAME, LINKAGE_SPEC)
Declare a new exception class named <NAME>Exception that derives from Exception This macro is typical...
This class can be used to store a global variable that is lazily initialized in a thread safe manner.
bool waitForInput(const Timeout &timeout=Timeout::infinite)
Wait for input on the socket for a specified length of time.
Socket()
Construct a non-SSL Socket.
SocketHandle_t getfd()
Get the socket handle for the socket.
static LazyGlobal< Socket::ShutDownMechanism_t, int, ShutDownMechanismFactory > s_shutDownMechanism
std::ostream & getOutputStream()
Get an ostream to write to the socket.
BLOCXX_DEPRECATED bool waitForOutput(int timeOutSecs)
Wait for output on the socket for a specified length of time.
BLOCXX_DEPRECATED void setTimeouts(int seconds)
Set all timeouts (send, receive, connect)
Timeout getSendTimeout() const
Get the send timeout.
void setConnectTimeout(const Timeout &timeout)
Set the connect timeout on the socket.
bool isConnected() const
Get connected state.
void setReceiveTimeout(const Timeout &timeout)
Set the receive timeout on the socket.
int read(void *dataIn, int dataInLen, ErrorAction errorAsException=E_RETURN_ON_ERROR)
Read from the socket.
void disconnect()
Disconnect the (presumably) open connection.
SocketAddress getPeerAddress() const
Get the peer address associated with the socket connection.
BLOCXX_DEPRECATED void setConnectTimeout(int seconds)
Set the connect timeout on the socket.
BLOCXX_DEPRECATED std::iostream & getIOStream()
Get an iostream to read/write from/to the socket.
Timeout getReceiveTimeout() const
Get the receive timeout.
bool waitForOutput(const Timeout &timeout=Timeout::infinite)
Wait for output on the socket for a specified length of time.
int write(const void *dataOut, int dataOutLen, ErrorAction errorAsException=E_RETURN_ON_ERROR)
Write some data to the socket.
static const int INFINITE_TIMEOUT BLOCXX_DEPRECATED
friend class ServerSocketImpl
static ShutDownMechanism_t getShutDownMechanism()
Timeout getConnectTimeout() const
Get the connect timeout.
BLOCXX_DEPRECATED void setReceiveTimeout(int seconds)
Set the receive timeout on the socket.
bool receiveTimeOutExpired() const
Has the receive timeout expired?
void connect(const SocketAddress &addr)
Connect to a peer node.
BLOCXX_DEPRECATED bool waitForInput(int timeOutSecs)
Wait for input on the socket for a specified length of time.
void setSendTimeout(const Timeout &timeout)
Set the send timeout on the socket.
BLOCXX_DEPRECATED void setSendTimeout(int seconds)
Set the send timeout on the socket.
std::istream & getInputStream()
Get an istream to read from the socket.
UnnamedPipeRef ShutDownMechanism_t
Select_t getSelectObj() const
SocketAddress getLocalAddress() const
Get the local address associated with the socket connection.
void setTimeouts(const Timeout &timeout)
Set all timeouts (send, receive, connect)
A timeout can be absolute, which means that it will happen at the specified DateTime.
static Timeout relative(float seconds)
IntrusiveReference< SocketBaseImpl > SocketBaseImplRef
IntrusiveReference< SSLServerCtx > SSLServerCtxRef
IntrusiveReference< UnnamedPipe > UnnamedPipeRef
IntrusiveReference< SSLClientCtx > SSLClientCtxRef
static Socket::ShutDownMechanism_t * create(int initVal)