Mixe for Privacy and Anonymity in the Internet
Public Member Functions | List of all members
CAClientSocket Class Referenceabstract

#include <CAClientSocket.hpp>

Inheritance diagram for CAClientSocket:
Collaboration diagram for CAClientSocket:

Public Member Functions

virtual ~CAClientSocket ()
 
virtual SINT32 sendFully (const UINT8 *buff, UINT32 len)=0
 Sends all data over the network. More...
 
virtual SINT32 receive (UINT8 *buff, UINT32 len)=0
 Will receive some bytes from the socket. More...
 
virtual SOCKET getSocket ()=0
 Returns the number of the Socket used. More...
 
SINT32 receiveFully (UINT8 *buff, UINT32 len)
 Receives all len bytes. More...
 

Detailed Description

Definition at line 32 of file CAClientSocket.hpp.

Constructor & Destructor Documentation

◆ ~CAClientSocket()

virtual CAClientSocket::~CAClientSocket ( )
inlinevirtual

Definition at line 35 of file CAClientSocket.hpp.

36  {
37  }

Member Function Documentation

◆ getSocket()

virtual SOCKET CAClientSocket::getSocket ( )
pure virtual

Returns the number of the Socket used.

Which will be always the same number, even after close(), until the Socket is recreated using create()

Returns
number of the associated socket

Implemented in CASocket.

Referenced by receiveFully().

Here is the caller graph for this function:

◆ receive()

virtual SINT32 CAClientSocket::receive ( UINT8 buff,
UINT32  len 
)
pure virtual

Will receive some bytes from the socket.

May block or not depending on the implementation.

Parameters
buffthe buffer which get the received data
lensize of buff
Returns
SOCKET_ERROR if an error occured
Return values
E_AGAIN,ifsocket was in non-blocking mode and receive would block or a timeout was reached
0if socket was gracefully closed
Returns
the number of bytes received (always >0)

Implemented in CATLSClientSocket, and CASocket.

Referenced by receiveFully().

Here is the caller graph for this function:

◆ receiveFully()

SINT32 CAClientSocket::receiveFully ( UINT8 buff,
UINT32  len 
)

Receives all len bytes.

This blocks until all bytes are received or an error occured.

Returns
E_UNKNOWN, in case of an error
E_SUCCESS otherwise

Definition at line 33 of file CAClientSocket.cpp.

34 {
35  SINT32 ret;
36  UINT32 pos = 0;
37 #ifdef __BUILD_AS_SHADOW_PLUGIN__
38  CASingleSocketGroup* pSocketGroup = new CASingleSocketGroup(false);
39  pSocketGroup->add(getSocket());
40 #endif
41  do
42  {
43 #ifdef __BUILD_AS_SHADOW_PLUGIN__
44  pSocketGroup->select();
45 #endif
46  ret = receive(buff + pos, len);
47  if (ret <= 0)
48  {
49  if (ret == E_AGAIN)
50  {
51 #ifndef __BUILD_AS_SHADOW_PLUGIN__
52  msSleep(100);
53 #endif
54  continue;
55  }
56  else
57  {
58 #ifdef __BUILD_AS_SHADOW_PLUGIN__
59  delete pSocketGroup;
60 #endif
61  return E_UNKNOWN;
62  }
63  }
64  pos += ret;
65  len -= ret;
66  } while (len > 0);
67 #ifdef __BUILD_AS_SHADOW_PLUGIN__
68  delete pSocketGroup;
69 #endif
70  return E_SUCCESS;
71 }
SINT32 msSleep(UINT32 ms)
Sleeps ms milliseconds.
Definition: CAUtil.cpp:406
signed int SINT32
Definition: basetypedefs.h:132
unsigned int UINT32
Definition: basetypedefs.h:131
virtual SINT32 receive(UINT8 *buff, UINT32 len)=0
Will receive some bytes from the socket.
virtual SOCKET getSocket()=0
Returns the number of the Socket used.
SINT32 add(SOCKET &s)
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
#define E_AGAIN
Definition: errorcodes.hpp:9
#define E_UNKNOWN
Definition: errorcodes.hpp:3
UINT16 len
Definition: typedefs.hpp:0

References CASocketGroup::add(), E_AGAIN, E_SUCCESS, E_UNKNOWN, getSocket(), len, msSleep(), receive(), and CASocketGroup::select().

Referenced by CALocalProxy::init(), CALocalProxy::processKeyExchange(), CAMuxSocket::receive(), and CAMuxSocket::receiveFully().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendFully()

virtual SINT32 CAClientSocket::sendFully ( const UINT8 buff,
UINT32  len 
)
pure virtual

Sends all data over the network.

This may block until all data is send.

Parameters
buff- the buffer of data to send
len- content length
Return values
E_UNKNOWN,ifan error occured
E_SUCCESS,ifsuccessful

Implemented in CATLSClientSocket, and CASocket.


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