Class CSpoofSocket::
ReceiveFrom()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: ReceiveNext page: ResolveDNS    Show member index
Protected Function Declared in:
SpoofSocket.h

'Declaration' icon -- Shortcut to top of page. Declaration

virtual int ReceiveFrom(
    char* pBuffer,
    unsigned long ulBufferLength,
    IP& rIP,
    unsigned short& rSourcePort);

'Description' icon -- Shortcut to top of page. Description

Recieve data from remote socket, saving the address

'Function Body' icon -- Shortcut to top of page. 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())
        {
            //Address
            rIP=((sockaddr_in*)&saConnected)->sin_addr.S_un.S_addr;

            //Port
            rSourcePort=htons(((sockaddr_in*)&saConnected)->sin_port);

            //Done
            return iResult;
        }
        else
        {
            //Error
            SetLastError("Receive");

            //Reset the data
            rIP=0;
            rSourcePort=0;

            //Done
            return iResult;
        }
    }
    else
    {
        //Report it
        ReportError("Receive","Can't run on TCP socket!");

        //Exit
        return GetErrorCode();
    }
}
ERROR_HANDLER_RETURN("Receive",GetErrorCode())

'See Also' icon -- Shortcut to top of page. See Also

Class Overview Class Overview  |  Public base class CSpoofBase  |  Hierarchy Chart Hierarchy Chart


Get Surveyor!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.