Thread portable class


Gate portable class


Timer class


Pool class


Terimber 2.0


About C++


Downloads Products & Services Support Clients Open Source About



Home / Open source / Terimber 2.0

terimber_socket Class Reference

socket class for xml http streams More...

#include <socket.h>

Inheritance diagram for terimber_socket:

stream_input_common

List of all members.

Public Member Functions

 terimber_socket (int num=(int) INVALID_SOCKET)
 constructor
 ~terimber_socket ()
 destructor
bool close ()
 closes and destroys terimber_socket
bool connect ()
 opens and connects terimber_socket to the previously set address
int send (const char *data, size_t len, size_t &timeout)
 sends known length data to destination while timeout
int receive (char *data, size_t len, size_t &timeout)
 receives known length data from source while timeout
int receive_whatever (char *data, size_t len, size_t &timeout, size_t &rlen)
 receives unknown length data from source while timeout
const sockaddr_in & get_address () const
 returns address
void set_address (const sockaddr_in &addr)
 sets address
int set_invalid ()
 invalidates socket
bool is_invalid () const
 checks socket validity

Static Public Member Functions

static void set_options (int number)
 sets options
static int resolve_address (const char *str, ub2_t port, sockaddr_in &addr)
 resolves string address
static void set_send_timeout (int number, size_t timeout)
 sets send timeout
static void set_recv_timeout (int number, size_t timeout)
 sets receive timeout

Private Attributes

SOCKET _number
 socket handle
sockaddr_in _addr
 socket address


Detailed Description

socket class for xml http streams

Definition at line 39 of file socket.h.


Constructor & Destructor Documentation

BEGIN_TERIMBER_NAMESPACE terimber_socket::terimber_socket ( int  num = (int)INVALID_SOCKET  ) 

constructor

For VC7, and VC8.

Parameters:
num  socket handle

Definition at line 44 of file socket.cpp.

References _addr.

terimber_socket::~terimber_socket (  ) 

destructor

Definition at line 50 of file socket.cpp.

References close().


Member Function Documentation

bool terimber_socket::close (  ) 

closes and destroys terimber_socket

Reimplemented in stream_input_common.

Definition at line 179 of file socket.cpp.

References _addr, and _number.

Referenced by stream_input_common::close(), connect(), stream_input_common::open(), and ~terimber_socket().

bool terimber_socket::connect (  ) 

opens and connects terimber_socket to the previously set address

Definition at line 230 of file socket.cpp.

References _addr, _number, close(), and set_options().

Referenced by stream_input_common::open().

int terimber_socket::send ( const char *  data,
size_t  len,
size_t &  timeout 
)

sends known length data to destination while timeout

Parameters:
data  buffer
len  buffer length
timeout  [in,out] timeout in milliseconds

Definition at line 254 of file socket.cpp.

References _number.

Referenced by stream_input_common::open().

int terimber_socket::receive ( char *  data,
size_t  len,
size_t &  timeout 
)

receives known length data from source while timeout

Parameters:
data  pre-allocated buffer
len  buffer length
timeout  [in,out] timeout in milliseconds

Definition at line 304 of file socket.cpp.

References _number.

Referenced by stream_input_common::data_request(), and stream_input_common::open().

int terimber_socket::receive_whatever ( char *  data,
size_t  len,
size_t &  timeout,
size_t &  rlen 
)

receives unknown length data from source while timeout

Parameters:
data  pre-allocated buffer
len  buffer length
timeout  [in,out] timeout in milliseconds
rlen  [out] received bytes

Definition at line 374 of file socket.cpp.

References _number.

const sockaddr_in& terimber_socket::get_address (  )  const [inline]

returns address

Definition at line 77 of file socket.h.

References _addr.

void terimber_socket::set_address ( const sockaddr_in &  addr  )  [inline]

sets address

Parameters:
addr  address to connect to

Definition at line 84 of file socket.h.

References _addr.

Referenced by stream_input_common::open().

void terimber_socket::set_options ( int  number  )  [static]

sets options

Parameters:
number  socket number

Definition at line 57 of file socket.cpp.

Referenced by connect().

int terimber_socket::resolve_address ( const char *  str,
ub2_t  port,
sockaddr_in &  addr 
) [static]

resolves string address

Parameters:
str  string address
port  port
addr  [out] address

Definition at line 79 of file socket.cpp.

Referenced by stream_input_common::open().

void terimber_socket::set_send_timeout ( int  number,
size_t  timeout 
) [static]

sets send timeout

Parameters:
number  socket handle
timeout  timeout in milliseconds

Definition at line 118 of file socket.cpp.

void terimber_socket::set_recv_timeout ( int  number,
size_t  timeout 
) [static]

sets receive timeout

Parameters:
number  socket handle
timeout  timeout in milliseconds

Definition at line 149 of file socket.cpp.

int terimber_socket::set_invalid (  ) 

invalidates socket

Definition at line 435 of file socket.cpp.

References _number.

bool terimber_socket::is_invalid (  )  const

checks socket validity

Definition at line 443 of file socket.cpp.

References _number.


Member Data Documentation

SOCKET terimber_socket::_number [private]

socket handle

Definition at line 120 of file socket.h.

Referenced by close(), connect(), is_invalid(), receive(), receive_whatever(), send(), and set_invalid().

sockaddr_in terimber_socket::_addr [private]

socket address

Definition at line 121 of file socket.h.

Referenced by close(), connect(), get_address(), set_address(), and terimber_socket().


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


© Copyright Terimber 2003-.