|
Mixe for Privacy and Anonymity in the Internet
|
#include <CADatagramSocket.hpp>
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 |
Definition at line 33 of file CADatagramSocket.hpp.
Definition at line 38 of file CADatagramSocket.cpp.
References m_Socket.
{
m_Socket=0;
// localPort=-1;
}
| CADatagramSocket::~CADatagramSocket | ( | ) | [inline] |
Definition at line 37 of file CADatagramSocket.hpp.
References close().
{close();}
| SINT32 CADatagramSocket::bind | ( | CASocketAddr & | psa | ) |
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;
}
| SINT32 CADatagramSocket::bind | ( | UINT16 | port | ) |
Definition at line 96 of file CADatagramSocket.cpp.
References bind().
{
CASocketAddrINet oSocketAddr(port);
return bind(oSocketAddr);
}
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);
}
| SINT32 CADatagramSocket::create | ( | int | type | ) |
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;
}
| SOCKET CADatagramSocket::getSocket | ( | ) | [inline] |
| 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;
}
| 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;
}
SOCKET CADatagramSocket::m_Socket [private] |
Definition at line 56 of file CADatagramSocket.hpp.
Referenced by bind(), CADatagramSocket(), close(), create(), getSocket(), receive(), and send().
1.7.6.1