| CTCPSocketAsync:: Connect() |

Public Function | Declared in: TCPSocketAsync.h

## Declaration

    virtual BOOL Connect(
        int iSourcePort,
        LPCSTR lpDestinationAddress,
        int iDestinationPort,
        BOOL bDisableAsync=FALSE);

## Description

Our async connection

## Function Body

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

        //Set the async notification
        if (!bDisableAsync)
        {
            int iResult;
            iResult=WSAAsyncSelect(GetHandle(),GetWindowHandle(),WM_SOCKET_CONNECT,FD_CONNECT);

            if (iResult)
            {
                CTCPSocket::SetLastError("Connect");
                return FALSE;
            }
        }

        //Call the original connect
        BOOL bResult;
        bResult=CTCPSocket::Connect(iSourcePort,lpDestinationAddress,iDestinationPort);

        if (bResult)
            AddSocketToList();
        else
            CTCPSocket::ReportError("Connect","Failed to connect!");

        return bResult;
    }
    ERROR_HANDLER_AMBIG_RETURN(CSpoofSocket,"Connect",FALSE)

## See Also

Class Overview | CTCPSocket | CAsyncSocket | 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.