Mixe for Privacy and Anonymity in the Internet
Public Member Functions | Private Attributes
CADatagramSocket Class Reference

#include <CADatagramSocket.hpp>

List of all members.

Public Member Functions

 CADatagramSocket ()
 ~CADatagramSocket ()
SINT32 create ()
SINT32 create (int type)
SINT32 close ()
SINT32 bind (CASocketAddr &psa)
SINT32 bind (UINT16 port)
SINT32 send (UINT8 *buff, UINT32 len, CASocketAddr &to)
SINT32 receive (UINT8 *buff, UINT32 len, CASocketAddr *from)
SOCKET getSocket ()

Private Attributes

SOCKET m_Socket

Detailed Description

Definition at line 33 of file CADatagramSocket.hpp.


Constructor & Destructor Documentation

Definition at line 38 of file CADatagramSocket.cpp.

References m_Socket.

  {
    m_Socket=0;
//    localPort=-1;
  }

Definition at line 37 of file CADatagramSocket.hpp.

References close().

{close();}

Here is the call graph for this function:


Member Function Documentation

Definition at line 86 of file CADatagramSocket.cpp.

References create(), E_SUCCESS, CASocketAddr::getSize(), CASocketAddr::getType(), CASocketAddr::LPSOCKADDR(), m_Socket, and SOCKET_ERROR.

Referenced by bind().

  {
//    localPort=-1;
    if(m_Socket==0&&create(from.getType())!=E_SUCCESS)
      return SOCKET_ERROR;
    if(::bind(m_Socket,from.LPSOCKADDR(),from.getSize())==SOCKET_ERROR)
        return SOCKET_ERROR;
    return E_SUCCESS;
  }

Here is the call graph for this function:

Definition at line 96 of file CADatagramSocket.cpp.

References bind().

  {
    CASocketAddrINet oSocketAddr(port);
    return bind(oSocketAddr);
  }

Here is the call graph for this function:

Definition at line 60 of file CADatagramSocket.cpp.

References closesocket, m_Socket, and SOCKET_ERROR.

Referenced by ~CADatagramSocket().

  {
//    EnterCriticalSection(&csClose);
//    localPort=-1;
    int ret;
    if(m_Socket!=0)
      {
  /*      LINGER linger;
        linger.l_onoff=1;
        linger.l_linger=0;
        if(::setsockopt(m_Socket,SOL_SOCKET,SO_LINGER,(char*)&linger,sizeof(linger))!=0)
          CAMsg::printMsg(LOG_DEBUG,"Fehler bei setsockopt - LINGER!\n");
  */      ::closesocket(m_Socket);
#ifdef _DEBUG
        sockets--;
#endif
        m_Socket=0;
        ret=0;
      }
    else
      ret=SOCKET_ERROR;
//    LeaveCriticalSection(&csClose);
    return ret;
  }

Definition at line 44 of file CADatagramSocket.cpp.

Referenced by bind().

  {
    return create(AF_INET);
  }

Definition at line 50 of file CADatagramSocket.cpp.

References E_SUCCESS, INVALID_SOCKET, m_Socket, and SOCKET_ERROR.

  {
    if(m_Socket==0)
      m_Socket=::socket(type,SOCK_DGRAM,0);
    if(m_Socket==INVALID_SOCKET)
      return SOCKET_ERROR;
//    localPort=-1;
    return E_SUCCESS;
  }

Definition at line 47 of file CADatagramSocket.hpp.

References m_Socket.

{return m_Socket;}
SINT32 CADatagramSocket::receive ( UINT8 buff,
UINT32  len,
CASocketAddr from 
)

Definition at line 110 of file CADatagramSocket.cpp.

References CASocketAddr::getSize(), m_Socket, and MSG_NOSIGNAL.

  {
    int ret;  
    if(from!=NULL)
      {
        socklen_t fromlen=from->getSize();
        ret=::recvfrom(m_Socket,(char*)buff,len,MSG_NOSIGNAL,(LPSOCKADDR)from,&fromlen);
      }
    else
      {
        ret=::recv(m_Socket,(char*)buff,len,MSG_NOSIGNAL);
      }
    return ret;           
  }

Here is the call graph for this function:

SINT32 CADatagramSocket::send ( UINT8 buff,
UINT32  len,
CASocketAddr to 
)

Definition at line 102 of file CADatagramSocket.cpp.

References E_SUCCESS, E_UNKNOWN, CASocketAddr::getSize(), CASocketAddr::LPSOCKADDR(), m_Socket, MSG_NOSIGNAL, and SOCKET_ERROR.

  {
        if(::sendto(m_Socket,(char*)buff,len,MSG_NOSIGNAL,to.LPSOCKADDR(),to.getSize())==SOCKET_ERROR)
      return E_UNKNOWN;
    return E_SUCCESS;           
  }

Here is the call graph for this function:


Member Data Documentation

Definition at line 56 of file CADatagramSocket.hpp.

Referenced by bind(), CADatagramSocket(), close(), create(), getSocket(), receive(), and send().


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