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); }
181 int write(
const void* dataOut,
int dataOutLen,
ErrorAction errorAsException = E_RETURN_ON_ERROR)
182 {
return m_impl->write(dataOut, dataOutLen, errorAsException); }
191 int read(
void* dataIn,
int dataInLen,
ErrorAction errorAsException = E_RETURN_ON_ERROR)
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;
298 return s_shutDownMechanism;
301 #ifndef BLOCXX_NO_SSL
313 bool peerCertVerified()
const;
328 #pragma warning (push)
329 #pragma warning (disable: 4251)
335 #pragma warning (pop)
SocketAddress getPeerAddress() const
Get the peer address associated with the socket connection.
std::istream & getInputStream()
Get an istream to read from the socket.
Timeout getConnectTimeout() const
Get the connect timeout.
void connect(const SocketAddress &addr)
Connect to a peer node.
int write(const void *dataOut, int dataOutLen, ErrorAction errorAsException=E_RETURN_ON_ERROR)
Write some data to the socket.
bool isConnected() const
Get connected state.
SocketAddress getLocalAddress() const
Get the local address associated with the socket connection.
BLOCXX_DEPRECATED void setSendTimeout(int seconds)
Set the send timeout on the socket.
const UInt32 INFINITE_TIMEOUT BLOCXX_DEPRECATED
Value that means infinite timeout.
BLOCXX_DEPRECATED void setTimeouts(int seconds)
Set all timeouts (send, receive, connect)
Select_t getSelectObj() const
static Socket::ShutDownMechanism_t * create(int initVal)
bool waitForOutput(const Timeout &timeout=Timeout::infinite)
Wait for output on the socket for a specified length of time.
void setReceiveTimeout(const Timeout &timeout)
Set the receive timeout on the socket.
Timeout getSendTimeout() const
Get the send timeout.
int read(void *dataIn, int dataInLen, ErrorAction errorAsException=E_RETURN_ON_ERROR)
Read from the socket.
std::ostream & getOutputStream()
Get an ostream to write to the socket.
static Timeout relative(float seconds)
void setSendTimeout(const Timeout &timeout)
Set the send timeout on the socket.
BLOCXX_DEPRECATED void setReceiveTimeout(int seconds)
Set the receive timeout on the socket.
BLOCXX_DEPRECATED bool waitForInput(int timeOutSecs)
Wait for input on the socket for a specified length of time.
A timeout can be absolute, which means that it will happen at the specified DateTime.
void setTimeouts(const Timeout &timeout)
Set all timeouts (send, receive, connect)
static ShutDownMechanism_t getShutDownMechanism()
UnnamedPipeRef ShutDownMechanism_t
void setConnectTimeout(const Timeout &timeout)
Set the connect timeout on the socket.
BLOCXX_DEPRECATED void setConnectTimeout(int seconds)
Set the connect timeout on the socket.
SocketHandle_t getfd()
Get the socket handle for the socket.
BLOCXX_DEPRECATED std::iostream & getIOStream()
Get an iostream to read/write from/to the socket.
This class can be used to store a global variable that is lazily initialized in a thread safe manner...
void disconnect()
Disconnect the (presumably) open connection.
#define BLOCXX_DECLARE_APIEXCEPTION(NAME, LINKAGE_SPEC)
Declare a new exception class named Exception that derives from Exception This macro is typical...
static LazyGlobal< Socket::ShutDownMechanism_t, int, ShutDownMechanismFactory > s_shutDownMechanism
bool receiveTimeOutExpired() const
Has the receive timeout expired?
Timeout getReceiveTimeout() const
Get the receive timeout.
bool waitForInput(const Timeout &timeout=Timeout::infinite)
Wait for input on the socket for a specified length of time.
BLOCXX_DEPRECATED bool waitForOutput(int timeOutSecs)
Wait for output on the socket for a specified length of time.