Socket Class Reference

#include <socket.h>


Public Types

enum  stype { TYPE_TCP, TYPE_UDP }
enum  state { STATE_EMPTY, STATE_IN, STATE_DISCONNECT }

Public Member Functions

 Socket (string ip, int port, stype _t=TYPE_TCP)
 ~Socket ()
bool recv (string &rez)
bool send (void *data, int len)
bool send (const string *data)
bool send (const string data)
bool send2v (void **v_ptr, int *v_len)
bool send3v (void **v_ptr, int *v_len)
void listen (int in)
Socketaccept (void)
state state_refresh (void)
int get_fd (void)
string source_ip (void)

Static Public Member Functions

static int poll (list< Socket * > &s)

Data Fields

int fd

Protected Member Functions

 Socket (int _fd, string _ip, int _port, stype _t)
bool _is_multicast (string ip)
unsigned long ip_to_number (string ip)

Protected Attributes

string ip
int port
stype type
state _state
int ttl
unsigned short ip_id
bool is_multicast


Detailed Description

Definition at line 25 of file socket.h.


Member Enumeration Documentation

enum Socket::stype

Enumerator:
TYPE_TCP 
TYPE_UDP 

Definition at line 27 of file socket.h.

enum Socket::state

Enumerator:
STATE_EMPTY 
STATE_IN 
STATE_DISCONNECT 

Definition at line 28 of file socket.h.


Constructor & Destructor Documentation

Socket::Socket ( string  ip,
int  port,
stype  _t = TYPE_TCP 
)

Definition at line 135 of file socket.cpp.

References _is_multicast(), _state, D, fd, flag, ip, is_multicast, memset(), port, STATE_EMPTY, t, type, TYPE_TCP, and TYPE_UDP.

Referenced by accept().

Socket::~Socket (  ) 

Definition at line 198 of file socket.cpp.

References fd.

Socket::Socket ( int  _fd,
string  _ip,
int  _port,
stype  _t 
) [protected]

Definition at line 188 of file socket.cpp.

References _state, D, fd, ip, port, STATE_EMPTY, and type.


Member Function Documentation

bool Socket::recv ( string &  rez  ) 

Definition at line 292 of file socket.cpp.

References buf, D, and fd.

bool Socket::send ( void *  data,
int  len 
)

Definition at line 311 of file socket.cpp.

References fd.

Referenced by Audio::process(), RTP_Stream::rtcp_send_sdes(), RTP_Stream::rtcp_send_sr(), and send().

bool Socket::send ( const string *  data  ) 

Definition at line 315 of file socket.cpp.

References fd, and send().

bool Socket::send ( const string  data  ) 

Definition at line 321 of file socket.cpp.

References fd, and send().

bool Socket::send2v ( void **  v_ptr,
int *  v_len 
)

Definition at line 345 of file socket.cpp.

References fd.

Referenced by Video::process().

bool Socket::send3v ( void **  v_ptr,
int *  v_len 
)

Definition at line 357 of file socket.cpp.

References fd.

Referenced by Video::process().

int Socket::poll ( list< Socket * > &  s  )  [static]

Definition at line 202 of file socket.cpp.

References D, fd, free(), malloc(), memset(), STATE_DISCONNECT, STATE_EMPTY, and STATE_IN.

Referenced by RTSP_Server::main().

void Socket::listen ( int  in  ) 

Definition at line 237 of file socket.cpp.

References fd.

Referenced by RTSP_Server::main().

Socket * Socket::accept ( void   ) 

Definition at line 246 of file socket.cpp.

References D, fd, memset(), s, Socket(), and type.

Referenced by RTSP_Server::main().

state Socket::state_refresh ( void   )  [inline]

Definition at line 45 of file socket.h.

References _state, and STATE_EMPTY.

int Socket::get_fd ( void   )  [inline]

Definition at line 50 of file socket.h.

References fd.

string Socket::source_ip ( void   )  [inline]

Definition at line 52 of file socket.h.

References ip.

bool Socket::_is_multicast ( string  ip  )  [protected]

Definition at line 118 of file socket.cpp.

References a, and ip_to_number().

Referenced by Socket().

unsigned long Socket::ip_to_number ( string  ip  )  [protected]

Definition at line 106 of file socket.cpp.

References String::split().

Referenced by _is_multicast().


Field Documentation

int Socket::fd

Definition at line 50 of file socket.h.

Referenced by accept(), get_fd(), listen(), poll(), recv(), send(), send2v(), send3v(), Socket(), and ~Socket().

string Socket::ip [protected]

Definition at line 58 of file socket.h.

Referenced by Socket(), and source_ip().

int Socket::port [protected]

Definition at line 59 of file socket.h.

Referenced by Socket().

stype Socket::type [protected]

Definition at line 60 of file socket.h.

Referenced by accept(), and Socket().

state Socket::_state [protected]

Definition at line 62 of file socket.h.

Referenced by Socket(), and state_refresh().

int Socket::ttl [protected]

Definition at line 64 of file socket.h.

unsigned short Socket::ip_id [protected]

Definition at line 65 of file socket.h.

bool Socket::is_multicast [protected]

Definition at line 68 of file socket.h.

Referenced by Socket().


The documentation for this class was generated from the following files:
Generated on Fri Nov 28 00:08:54 2008 for elphel by  doxygen 1.5.1