aagosh
aagosh

Reputation: 107

RasDial Returns 633 in MFC Application

I am using RasDial API inside an MFC application. It turns out that API returns always 633 (The Port Is in Use or Not Configured) while the same code works fine in a command line application.

Here is the code snippet

    RASDIALPARAMS rdParams;
    ZeroMemory(&rdParams, sizeof(RASDIALPARAMS));
    rdParams.dwSize = sizeof(RASDIALPARAMS);
    _tcscpy(rdParams.szEntryName, TEXT("VPN"));
    m_hRasConn = 0;
    DWORD dwRet = RasDial( NULL, NULL, &rdParams, 1, NULL, &m_hRasConn);

The phone book entry for VPN is perfect, it works always when I manually connect and also when I use rasdial.exe The same entry can be dialed when I use above code inside a command line application but never works when I use it inside MFC application.

Any idea what could go wrong?

Upvotes: 0

Views: 340

Answers (1)

Jeff Winn
Jeff Winn

Reputation: 804

From what I can tell, your call to RasDial looks fine.

I remember having this problem during initial development of DotRas. If it's what I'm thinking, if you're testing your application and close the application while a connection attempt is in progress, the RAS state machine gets confused and the connection is left open until you restart (pretty much all versions of Windows pre-Windows 8 exhibit this behavior) the machine.

What this means is, once you start a connection, do not close your application unless you call RasHangUp on the handle that RasDial returned to you if it hasn't finished connecting.

Upvotes: 0

Related Questions