| CSpoofSocket:: Receive() |

Public Function | Declared in: SpoofSocket.h

## Declaration

    virtual int Receive(
        char* buf,
        int bufLen);

## Description

Recieve data from remote socket

## Function Body

    try
    {
        if (!ValidSocket())
            return SOCKET_ERROR;

        //Receive data
        int iResult;

        //Receive
        if (m_Protocol!=IPPROTO_TCP)
        {
            sockaddr saConnected;

            int iTmp;
            iTmp=sizeof(saConnected);

            //Accept it
            iResult=recvfrom(GetHandle(),buf,bufLen,NULL,&saConnected,&iTmp);

            //If OK set it
            if (iResult!=SOCKET_ERROR)
                memcpy(&m_ConnectedTo,&saConnected,sizeof(saConnected));
        }
        else
            iResult=recv(GetHandle(),buf,bufLen,NULL);

        //Check if error
        if (iResult==SOCKET_ERROR)
            //Error
            SetLastError("Receive");

        //Number of bytes received
        return iResult;
    }
    ERROR_HANDLER_RETURN("Receive",SOCKET_ERROR)

## See Also

Class Overview | CSpoofBase | Hierarchy Chart

This web site was generated using Surveyor V4.50.811.1. Click here for more information. | Site content copyright © 2001 Barak Weichselbaum. See the About page for additional notices. This page last updated: 27 Jun 2001.