Pol  Revision:cb584c9
Pol::Clib::Socket Class Reference

#include <wnsckt.h>

Public Types

enum  option { none = 0, nonblocking = 1, reuseaddr = 2 }
 

Public Member Functions

 Socket ()
 
 Socket (SOCKET sock)
 
 Socket (Socket &sck)
 
virtual ~Socket ()
 
bool accept (SOCKET *s, unsigned int mstimeout)
 
bool accept (Socket &newsocket)
 
void close ()
 
bool connected () const
 
void disable_nagle ()
 
std::string getpeername () const
 
SOCKET handle () const
 
bool is_local () const
 
bool listen (unsigned short port)
 
bool open (const char *ipaddr, unsigned short port)
 
unsigned peek (void *vdest, unsigned len, unsigned int waitms)
 
struct sockaddr peer_address () const
 
bool recvbyte (unsigned char *byte, unsigned int waitms)
 
bool recvdata (void *vdest, unsigned len, unsigned int waitms)
 
SOCKET release_handle ()
 
bool select (unsigned int seconds, unsigned int useconds)
 
void send (const void *data, unsigned length)
 
bool send_nowait (const void *vdata, unsigned datalen, unsigned *nsent)
 
void set_options (option opt)
 
void setpeer (struct sockaddr peer)
 
void setsocket (SOCKET sck)
 
void takesocket (Socket &sck)
 
void write (const std::string &str)
 

Protected Member Functions

void apply_prebind_socket_options (SOCKET sck)
 
void apply_socket_options (SOCKET sck)
 

Private Member Functions

void HandleError ()
 

Private Attributes

int _options
 
struct sockaddr _peer
 
SOCKET _sck
 

Detailed Description

Definition at line 20 of file wnsckt.h.

Member Enumeration Documentation

Enumerator
none 
nonblocking 
reuseaddr 

Definition at line 23 of file wnsckt.h.

Constructor & Destructor Documentation

Pol::Clib::Socket::Socket ( )

Definition at line 45 of file wnsckt.cpp.

References _peer, and Pol::Testing::dummy().

Pol::Clib::Socket::Socket ( SOCKET  sock)
explicit

Definition at line 59 of file wnsckt.cpp.

References _peer.

Pol::Clib::Socket::Socket ( Socket sck)

Definition at line 64 of file wnsckt.cpp.

References _peer, _sck, and INVALID_SOCKET.

Pol::Clib::Socket::~Socket ( )
virtual

Definition at line 71 of file wnsckt.cpp.

References close().

Member Function Documentation

bool Pol::Clib::Socket::accept ( SOCKET s,
unsigned int  mstimeout 
)

Definition at line 275 of file wnsckt.cpp.

References _sck, apply_socket_options(), and INVALID_SOCKET.

Referenced by Pol::Clib::SocketListener::accept(), and accept().

bool Pol::Clib::Socket::accept ( Socket newsocket)

Definition at line 290 of file wnsckt.cpp.

References _sck, accept(), apply_socket_options(), INVALID_SOCKET, setpeer(), and setsocket().

void Pol::Clib::Socket::apply_prebind_socket_options ( SOCKET  sck)
protected

Definition at line 199 of file wnsckt.cpp.

References _options, Pol::Clib::decint(), INVALID_SOCKET, and reuseaddr.

Referenced by listen().

void Pol::Clib::Socket::apply_socket_options ( SOCKET  sck)
protected

Definition at line 179 of file wnsckt.cpp.

References _options, Pol::Clib::decint(), and nonblocking.

Referenced by accept(), and listen().

void Pol::Clib::Socket::disable_nagle ( )

Definition at line 164 of file wnsckt.cpp.

References _sck, Pol::Clib::decint(), and INVALID_SOCKET.

Referenced by Pol::Core::UoClientThread::create().

std::string Pol::Clib::Socket::getpeername ( ) const
SOCKET Pol::Clib::Socket::handle ( ) const

Definition at line 112 of file wnsckt.cpp.

References _sck.

Referenced by Pol::Core::http_func().

void Pol::Clib::Socket::HandleError ( )
private

Definition at line 314 of file wnsckt.cpp.

References close(), and INFO_PRINT.

Referenced by listen(), peek(), recvbyte(), recvdata(), send(), and send_nowait().

bool Pol::Clib::Socket::is_local ( ) const

Definition at line 638 of file wnsckt.cpp.

References getpeername().

Referenced by Pol::Core::http_func().

bool Pol::Clib::Socket::listen ( unsigned short  port)
bool Pol::Clib::Socket::open ( const char *  ipaddr,
unsigned short  port 
)

Definition at line 125 of file wnsckt.cpp.

References _sck, close(), INFO_PRINT, and INVALID_SOCKET.

Referenced by Pol::Module::OSExecutorModule::mf_OpenConnection().

unsigned Pol::Clib::Socket::peek ( void *  vdest,
unsigned  len,
unsigned int  waitms 
)
struct sockaddr Pol::Clib::Socket::peer_address ( ) const

Definition at line 107 of file wnsckt.cpp.

References _peer.

Referenced by Pol::Core::UoClientThread::create(), and Pol::Network::AuxClientThread::init().

bool Pol::Clib::Socket::recvbyte ( unsigned char *  byte,
unsigned int  waitms 
)
bool Pol::Clib::Socket::recvdata ( void *  vdest,
unsigned  len,
unsigned int  waitms 
)
SOCKET Pol::Clib::Socket::release_handle ( )

Definition at line 117 of file wnsckt.cpp.

References _sck, and INVALID_SOCKET.

Referenced by Pol::Core::UoClientThread::create().

bool Pol::Clib::Socket::select ( unsigned int  seconds,
unsigned int  useconds 
)
void Pol::Clib::Socket::send ( const void *  data,
unsigned  length 
)
bool Pol::Clib::Socket::send_nowait ( const void *  vdata,
unsigned  datalen,
unsigned *  nsent 
)
void Pol::Clib::Socket::set_options ( option  opt)

Definition at line 82 of file wnsckt.cpp.

References _options.

Referenced by Pol::Clib::SocketListener::SocketListener().

void Pol::Clib::Socket::setpeer ( struct sockaddr  peer)

Definition at line 87 of file wnsckt.cpp.

References _peer.

Referenced by accept().

void Pol::Clib::Socket::setsocket ( SOCKET  sck)

Definition at line 76 of file wnsckt.cpp.

References _sck, and close().

Referenced by accept().

void Pol::Clib::Socket::takesocket ( Socket sck)
void Pol::Clib::Socket::write ( const std::string &  str)

Definition at line 617 of file wnsckt.cpp.

References send().

Member Data Documentation

int Pol::Clib::Socket::_options
private

Definition at line 75 of file wnsckt.h.

Referenced by apply_prebind_socket_options(), apply_socket_options(), and set_options().

struct sockaddr Pol::Clib::Socket::_peer
private

Definition at line 76 of file wnsckt.h.

Referenced by peer_address(), setpeer(), and Socket().


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