クラス rcsc::BasicSocket

socket class [詳細]

#include <basic_socket.h>

rcsc::BasicSocketに対する継承グラフ

rcsc::TCPSocket rcsc::UDPSocket すべてのメンバ一覧

Public 型

enum  SocketType { DATAGRAM_TYPE, STREAM_TYPE }

Public メソッド

virtual ~BasicSocket ()
 destructor. close socket automatically
int fd () const
 returns socket file descriptor
bool isOpen () const
 check if socket is opened or not.
int close ()
 close socket
virtual int send (const char *data, const std::size_t len)=0
 send stream data to the connected host.
virtual int receive (char *buf, const std::size_t len)=0
 receive stream data from the connected remote host.

Protected メソッド

 BasicSocket ()
 constructor for server socket
void setDestPort (const void *addr)
 set distination port
bool open (const SocketType type)
 open socket
bool bind (const int port=0)
 bind the socket to local address
bool setAddr (const char *hostname, const int port)
 set the address info of the specified remote host.
int setNonBlocking ()
 set non blocking mode.
int connectToPresetAddr ()
 connect to address set by setAddr()
int writeToStream (const char *data, const std::size_t len)
 send stream data to the connected host.
int readFromStream (char *buf, const std::size_t len)
 receive stream data from the connected remote host.
int sendDatagramPacket (const char *data, const std::size_t len)
 send datagram data to the connected host.
int receiveDatagramPacket (char *buf, const std::size_t len, const bool overwrite_dist_addr=false)
 receive datagram data from the connected remote host.

Protected 変数

boost::scoped_ptr< AddrImplM_dest
 destination address

説明

socket class


コンストラクタとデストラクタ

rcsc::BasicSocket::BasicSocket (  )  [protected]

constructor for server socket

引数:
port port number to receive packet.


関数

void rcsc::BasicSocket::setDestPort ( const void *  addr  )  [protected]

set distination port

引数:
addr address implementation dependent address

bool rcsc::BasicSocket::open ( const SocketType  type  )  [protected]

open socket

戻り値:
value of close(fd) if socket is opened.

bool rcsc::BasicSocket::bind ( const int  port = 0  )  [protected]

bind the socket to local address

引数:
port port number to be binded.
戻り値:
true if successfully binded.

bool rcsc::BasicSocket::setAddr ( const char *  hostname,
const int  port 
) [protected]

set the address info of the specified remote host.

引数:
hostname the name of remote host.(or IP address)
port port number of remote host.
戻り値:
true if generated binary address of remote host.

int rcsc::BasicSocket::setNonBlocking (  )  [protected]

set non blocking mode.

戻り値:
returned value of fcntl()

int rcsc::BasicSocket::connectToPresetAddr (  )  [protected]

connect to address set by setAddr()

戻り値:
0 if successful, otherwise -1

int rcsc::BasicSocket::writeToStream ( const char *  data,
const std::size_t  len 
) [protected]

send stream data to the connected host.

引数:
data the pointer to the data to be sent.
len the length of data.
戻り値:
the length of sent data if successfuly sent, otherwise -1.

int rcsc::BasicSocket::readFromStream ( char *  buf,
const std::size_t  len 
) [protected]

receive stream data from the connected remote host.

引数:
buf buffer to receive data
len maximam length of receive buffer
戻り値:
0 error occured and errno is EWOULDBLOCK
-1 error occured
戻り値:
the length of received data.

int rcsc::BasicSocket::sendDatagramPacket ( const char *  data,
const std::size_t  len 
) [protected]

send datagram data to the connected host.

引数:
msg the pointer to the data to be sent.
len the length of data.
戻り値:
the length of sent data if successfuly sent, otherwise -1.

int rcsc::BasicSocket::receiveDatagramPacket ( char *  buf,
const std::size_t  len,
const bool  overwrite_dist_addr = false 
) [protected]

receive datagram data from the connected remote host.

引数:
buf buffer to receive data
len maximal length of buffer buf
overwrite_dist_addr if this value is true, set distination address to sender address of this packet.
戻り値:
0 error occured and errno is EWOULDBLOCK
-1 error occured
戻り値:
the length of received data.

bool rcsc::BasicSocket::isOpen (  )  const [inline]

check if socket is opened or not.

戻り値:
true if socket has the valid file descripter.

int rcsc::BasicSocket::close (  ) 

close socket

戻り値:
value that close(fd) returns if socket is opened, otherwise 0.

virtual int rcsc::BasicSocket::send ( const char *  data,
const std::size_t  len 
) [pure virtual]

send stream data to the connected host.

引数:
data the pointer to the data to be sent.
len the length of data.
戻り値:
the length of sent data if successfuly sent, otherwise -1.

rcsc::TCPSocketrcsc::UDPSocketで実装されています。

virtual int rcsc::BasicSocket::receive ( char *  buf,
const std::size_t  len 
) [pure virtual]

receive stream data from the connected remote host.

引数:
buf buffer to receive data
len maximal length of buffer buf
戻り値:
0 error occured and errno is EWOULDBLOCK
-1 error occured
戻り値:
the length of received data.

rcsc::TCPSocketrcsc::UDPSocketで実装されています。


このクラスの説明は次のファイルから生成されました:
librcscに対してThu May 1 15:41:26 2008に生成されました。  doxygen 1.5.0