26 virtual void InternalSetSockOpt(
int level,
int optname,
const char * optval,
int optlen);
30 virtual void InternalCreate(
int af = AF_INET,
int type = SOCK_STREAM,
int protocol = IPPROTO_IP, LPWSAPROTOCOL_INFO lpProtocolInfo = NULL, GROUP g = NULL, DWORD dwFlags = 0);
32 virtual void InternalConnect(
const struct sockaddr * name,
int namelen, LPWSABUF lpCallerData = NULL, LPWSABUF lpCalleeData = NULL, LPQOS lpSQOS = NULL, LPQOS lpGQOS = NULL);
50 void Select(
bool read,
bool write,
bool except,
const int timeout_in_seconds,
bool& timed_out);
58 void Socket::Connect(
const std::wstring& ip_addr,
unsigned port,
int type = SOCK_STREAM,
int protocol = IPPROTO_IP);
60 void Connect(
const std::string& ip_addr,
unsigned port,
int type = SOCK_STREAM,
int protocol = IPPROTO_IP);
62 void Connect(
const struct sockaddr * name,
int namelen);
66 void Bind(
const std::string& ip_addr,
unsigned port,
int type = SOCK_STREAM,
int protocol = IPPROTO_IP);
void SetSocketReuse()
Turn on the resue address option. Allows the socket to be bound to an address that is already in use...
Definition: Socket.cpp:72
int GetError() const
Definition: Socket.h:40
A basic blocking socket.
Definition: Socket.h:19
Socket()
constructor
Definition: Socket.cpp:6
bool IsCreated() const
Returns true if the socket has been created.
Definition: Socket.h:46
virtual ~Socket()
Definition: Socket.cpp:14
void Disconnect()
Shutdown, receive out-of-band data and close the socket (disconnect from a remote host)...
Definition: Socket.cpp:124
virtual void InternalClose()
Close a socket.
Definition: Socket.cpp:49
virtual void InternalSetSockOpt(int level, int optname, const char *optval, int optlen)
Set a socket option.
Definition: Socket.cpp:31
void SetHardClose(unsigned short timeout=0)
Turn on the linger option. Closing a socket does not wait for for the session to breakdown, unless you have requested it by setting the linger socket option.
Definition: Socket.cpp:60
virtual void InternalIoCtlSocket(long cmd, u_long *argp)
Control socket IO.
Definition: Socket.cpp:40
bool m_connected
Definition: Socket.h:24
virtual void InternalConnect(const struct sockaddr *name, int namelen, LPWSABUF lpCallerData=NULL, LPWSABUF lpCalleeData=NULL, LPQOS lpSQOS=NULL, LPQOS lpGQOS=NULL)
Connect a socket. See WSAConnect or ::connect for more information.
Definition: Socket.cpp:92
void ClearError()
Clear the error from the last failed operation on this socket.
Definition: Socket.h:42
virtual void InternalShutdown(int how)
Shutdown a socket.
Definition: Socket.cpp:22
void Bind(const std::string &ip_addr, unsigned port, int type=SOCK_STREAM, int protocol=IPPROTO_IP)
Bind the socket to an address.
Definition: Socket.cpp:147
void Select(bool read, bool write, bool except, const int timeout_in_seconds, bool &timed_out)
The select function determines the status of the socket, waiting if necessary, to perform synchronous...
SOCKET Peek() const
Definition: Socket.h:44
int m_error
Definition: Socket.h:23
virtual void InternalCreate(int af=AF_INET, int type=SOCK_STREAM, int protocol=IPPROTO_IP, LPWSAPROTOCOL_INFO lpProtocolInfo=NULL, GROUP g=NULL, DWORD dwFlags=0)
Create a socket. See WSASocket or ::socket for more information.
Definition: Socket.cpp:78
void SetGracefulClose()
Turn off the linger option. Closing a socket does not wait for for the session to breakdown...
Definition: Socket.cpp:66
void Connect(const std::string &ip_addr, unsigned port, int type=SOCK_STREAM, int protocol=IPPROTO_IP)
Initialize the socket and connect to a destination. Defaults to TCP, specify SOCK_DGRAM for UDP...
Definition: Socket.cpp:109
bool IsConnected() const
Returns true if the socket has been successfuly connected.
Definition: Socket.h:48
SOCKET m_socket
Definition: Socket.h:22