Class CSpoofSocket::
Create()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: ConstructStaticIPHeaderNext page: CSpoofSocket    Show member index
Public Function Declared in:
SpoofSocket.h

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

BOOL Create(
    int iProtocol);

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

Create a socket

'Function Body' icon -- Shortcut to top of page. Function Body

try
{
    //Here we create the raw socket
    if (m_Raw || iProtocol==IPPROTO_ICMP)
        m_SpoofSocket=socket(AF_INET,SOCK_RAW,iProtocol);//iProtocol);
    else
        if (iProtocol==IPPROTO_TCP)
            m_SpoofSocket=socket(AF_INET,SOCK_STREAM,iProtocol);
        else if (iProtocol==IPPROTO_UDP)
            m_SpoofSocket=socket(AF_INET,SOCK_DGRAM,iProtocol);

    //Check for socket validity
    if (m_SpoofSocket==INVALID_SOCKET)
    {
        //Error
        SetLastError("Create");
        return FALSE;
    }

    if (m_Raw)
    {
        //Set that the application will send the IP header
        unsigned int iTrue=1;

        if(setsockopt(m_SpoofSocket,IPPROTO_IP,IP_HDRINCL,(char*)&iTrue,sizeof(iTrue))==SOCKET_ERROR)
        {
            //Check for options error
            SetLastError("Create");
            return FALSE;
        }
    }

    return TRUE;
}
ERROR_HANDLER_RETURN("Create",FALSE)

'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 © 2001 Barak Weichselbaum. See the About page for additional notices. This page last updated: 24 Apr 2001.