Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOCKETALT Class Reference

#include <vsnet_socket.h>

Classes

class  CompareLt
 

Public Member Functions

 SOCKETALT ()
 
 SOCKETALT (const SOCKETALT &orig)
 
 SOCKETALT (VsnetSocket *sock)
 
 SOCKETALT (int sock, bool mode, const AddressIP &remote_ip, SocketSet &set)
 
SOCKETALToperator= (const SOCKETALT &orig)
 
int get_fd () const
 
bool valid () const
 
bool isTcp () const
 
int queueLen (int pri)
 
int optPayloadSize () const
 
bool isActive ()
 
int sendbuf (Packet *packet, const AddressIP *to, int pcktflags)
 
bool set_nonblock ()
 
bool set_block ()
 
int recvbuf (Packet *p, AddressIP *ipadr)
 
void disconnect (const char *s)
 
bool sameAddress (const SOCKETALT &l) const
 
bool lowerAddress (const SOCKETALT &l) const
 
void addToSet (SocketSet &set)
 
void setSet (SocketSet *set)
 
const AddressIPgetRemoteAddress () const
 
bool setRemoteAddress (const AddressIP &)
 
const AddressIPgetLocalAddress () const
 
bool setLocalAddress (const AddressIP &)
 

Friends

class CompareLt
 
std::ostream & operator<< (std::ostream &ostr, const SOCKETALT &s)
 
bool operator== (const SOCKETALT &l, const SOCKETALT &r)
 

Detailed Description

Definition at line 34 of file vsnet_socket.h.

Constructor & Destructor Documentation

SOCKETALT::SOCKETALT ( )

Definition at line 20 of file vsnet_socket.cpp.

21 {}
SOCKETALT::SOCKETALT ( const SOCKETALT orig)

Definition at line 31 of file vsnet_socket.cpp.

32 {
33  _sock = orig._sock;
34 }
SOCKETALT::SOCKETALT ( VsnetSocket sock)

Definition at line 36 of file vsnet_socket.cpp.

37 {
38  _sock = ptr( s );
39 }
SOCKETALT::SOCKETALT ( int  sock,
bool  mode,
const AddressIP remote_ip,
SocketSet set 
)

Definition at line 23 of file vsnet_socket.cpp.

24 {
25  if (mode == TCP)
26  _sock = ptr( new VsnetTCPSocket( sock, remote_ip, sets ) );
27  else
28  _sock = ptr( new VsnetUDPSocket( sock, remote_ip, sets ) );
29 }

Member Function Documentation

void SOCKETALT::addToSet ( SocketSet set)

Definition at line 185 of file vsnet_socket.cpp.

References SocketSet::set().

186 {
187  if (_sock) sockset.set( &(*this->_sock) );
188 }
void SOCKETALT::disconnect ( const char *  s)

Definition at line 158 of file vsnet_socket.cpp.

Referenced by NetClient::init(), and NetClient::logout().

159 {
160  if (_sock) _sock->disconnect( s );
161 }
int SOCKETALT::get_fd ( ) const

Definition at line 47 of file vsnet_socket.cpp.

Referenced by NetUITCP::createSocket(), VsnetDownload::Client::Item::get_fd(), and NetClient::logout().

48 {
49  return !_sock ? -1 : _sock->get_fd();
50 }
const AddressIP & SOCKETALT::getLocalAddress ( ) const

Definition at line 204 of file vsnet_socket.cpp.

Referenced by NetUIUDP::disconnectSaveUDP().

205 {
206  static AddressIP nullAdr;
207  if (_sock)
208  return _sock->getLocalAddress();
209  else
210  return nullAdr; //just in case.
211 }
const AddressIP & SOCKETALT::getRemoteAddress ( ) const

Definition at line 195 of file vsnet_socket.cpp.

Referenced by Client::Client().

196 {
197  static AddressIP nullAdr;
198  if (_sock)
199  return _sock->getRemoteAddress();
200  else
201  return nullAdr; //just in case.
202 }
bool SOCKETALT::isActive ( )

Definition at line 115 of file vsnet_socket.cpp.

Referenced by NetClient::checkMsg(), and AccountServer::start().

116 {
117  if (!_sock) {
118  return false;
119  } else {
120  bool r = _sock->isActive();
121  return r;
122  }
123 }
bool SOCKETALT::isTcp ( ) const

Definition at line 58 of file vsnet_socket.cpp.

Referenced by NetClient::synchronizeTime().

59 {
60  return !_sock ? false : _sock->isTcp();
61 }
bool SOCKETALT::lowerAddress ( const SOCKETALT l) const

Definition at line 173 of file vsnet_socket.cpp.

Referenced by SOCKETALT::CompareLt::operator()().

174 {
175  if (!_sock) {
176  if (right._sock) return true;
177  return false;
178  } else if (!right._sock) {
179  return false;
180  } else {
181  return this->_sock->lt( *right._sock );
182  }
183 }
SOCKETALT & SOCKETALT::operator= ( const SOCKETALT orig)

Definition at line 41 of file vsnet_socket.cpp.

42 {
43  _sock = orig._sock;
44  return *this;
45 }
int SOCKETALT::optPayloadSize ( ) const

Definition at line 68 of file vsnet_socket.cpp.

69 {
70  return !_sock ? -1 : _sock->optPayloadSize();
71 }
int SOCKETALT::queueLen ( int  pri)

Definition at line 63 of file vsnet_socket.cpp.

64 {
65  return !_sock ? -1 : _sock->queueLen( pri );
66 }
int SOCKETALT::recvbuf ( Packet p,
AddressIP ipadr 
)

Definition at line 148 of file vsnet_socket.cpp.

Referenced by AccountServer::recvMsg().

149 {
150  if (!_sock || !p) {
151  return -1;
152  } else {
153  int retval = _sock->recvbuf( p, ipadr );
154  return retval;
155  }
156 }
bool SOCKETALT::sameAddress ( const SOCKETALT l) const

Definition at line 163 of file vsnet_socket.cpp.

164 {
165  if (!l._sock)
166  return (!_sock) ? true : false;
167  else if (!_sock)
168  return false;
169  else
170  return _sock->eq( *l._sock );
171 }
int SOCKETALT::sendbuf ( Packet packet,
const AddressIP to,
int  pcktflags 
)

Definition at line 125 of file vsnet_socket.cpp.

126 {
127  if (!_sock || !packet)
128  return -1;
129  else
130  return _sock->sendbuf( packet, to, pcktflags );
131 }
bool SOCKETALT::set_block ( )

Definition at line 143 of file vsnet_socket.cpp.

Referenced by NetClient::synchronizeTime().

144 {
145  return !_sock ? false : _sock->set_block();
146 }
bool SOCKETALT::set_nonblock ( )

Definition at line 138 of file vsnet_socket.cpp.

Referenced by NetUIUDP::createServerSocket(), NetUITCP::createSocket(), NetUIUDP::createSocket(), and NetClient::synchronizeTime().

139 {
140  return !_sock ? false : _sock->set_nonblock();
141 }
bool SOCKETALT::setLocalAddress ( const AddressIP inp)

Definition at line 95 of file vsnet_socket.cpp.

Referenced by NetUIUDP::createServerSocket(), and NetUIUDP::createSocket().

96 {
97  if (!_sock) {
98  return false;
99  } else {
100  bool r = _sock->setLocalAddress( inp );
101  return r;
102  }
103 }
bool SOCKETALT::setRemoteAddress ( const AddressIP inp)

Definition at line 105 of file vsnet_socket.cpp.

Referenced by NetUIUDP::createSocket(), and NetClient::synchronizeTime().

106 {
107  if (!_sock) {
108  return false;
109  } else {
110  bool r = _sock->setRemoteAddress( inp );
111  return r;
112  }
113 }
void SOCKETALT::setSet ( SocketSet set)

Definition at line 190 of file vsnet_socket.cpp.

Referenced by NetUIUDP::createSocket(), and NetUIUDP::disconnectSaveUDP().

191 {
192  if (_sock) _sock->setSet( set );
193 }
bool SOCKETALT::valid ( ) const

Definition at line 52 of file vsnet_socket.cpp.

Referenced by NetClient::connectLoad(), NetUIUDP::disconnectSaveUDP(), NetClient::init(), NetClient::logout(), AccountServer::start(), and NetClient::synchronizeTime().

53 {
54  if (!_sock) return false;
55  return _sock->valid();
56 }

Friends And Related Function Documentation

friend class CompareLt
friend

Required by the download manager achieve a sorting of sockets.

Definition at line 83 of file vsnet_socket.h.

std::ostream& operator<< ( std::ostream &  ostr,
const SOCKETALT s 
)
friend

Definition at line 73 of file vsnet_socket.cpp.

74 {
75  if (s._sock) s._sock->dump( ostr );
76  else ostr<<"NULL";
77  return ostr;
78 }
bool operator== ( const SOCKETALT l,
const SOCKETALT r 
)
friend

Definition at line 80 of file vsnet_socket.cpp.

81 {
82  if (!l._sock)
83  return (!r._sock) ? true : false;
84  else if (!r._sock)
85  return false;
86  else
87  return l._sock->eq( *r._sock );
88 }

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