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

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

virtual BOOL Bind(
    LPCSTR lpSourceAddress,
    int iPort=0);

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

Bind to a specific address

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

try
{
    //Quit if not ok
    if (!CheckSocketValid())
        return FALSE;

    //Create the local address
    sockaddr_in soSrc;

    //Set to 0
    memset(&soSrc,0,sizeof(soSrc));
    soSrc.sin_family=AF_INET;

    if (lpSourceAddress)
        soSrc.sin_addr.s_addr=inet_addr(lpSourceAddress);
    else
        soSrc.sin_addr.s_addr=ADDR_ANY ;

    soSrc.sin_port=htons(iPort);

    //Now we need to bind it
    if (bind(GetHandle(),(sockaddr*)&soSrc,sizeof(soSrc)))
    {
        //Error
        SetLastError("Bind");
        return FALSE;
    }
    else
        //Save the address
        m_ConnectedTo=soSrc;

    //If already has a source address then don't change it
    if (!m_SourceAddress)
        m_SourceAddress=lpSourceAddress;

    return TRUE;
}
ERROR_HANDLER_RETURN("Bind",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: 27 Jun 2001.