![]() |
Receive() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Public Function |
Declared in: SpoofSocket.h |
Declaration
virtual int Receive(
char* pBuffer,
unsigned long ulBufferLength);
DescriptionRecieve data from remote socket, can be used with all sub sockets (protocols) Return value: Positive - The number of bytes received. Zero - Socket has been closed. Negative - Error
Function Body
try
{
if (!ValidSocket() ||
!pBuffer ||
!ulBufferLength)
return GetErrorCode();
//Receive data
int iResult;
//Receive
if (m_ucProtocol!=IPPROTO_TCP &&
!m_bSniffing)
{
//Get the remote address
sockaddr saConnected;
int iTmp;
iTmp=sizeof(saConnected);
//Accept it
iResult=recvfrom(GetHandle(),
pBuffer,
ulBufferLength,
NULL,
&saConnected,
&iTmp);
//If OK set it
if (iResult!=GetErrorCode())
//Take the connected to data
memcpy(&m_aConnectedTo,
&saConnected,
sizeof(saConnected));
}
else
//Do a regular receive
iResult=recv(GetHandle(),
pBuffer,
ulBufferLength,
NULL);
//Check if error
if (iResult==GetErrorCode() &&
GetSystemLastError()!=WSAEWOULDBLOCK)
//Error
SetLastError("Receive");
//Number of bytes received
return iResult;
}
ERROR_HANDLER_RETURN("Receive",GetErrorCode())
See Also
This web site was generated
using Surveyor V4.50.811.1. Click
here
for more information. |
Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003. |