Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8206675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:45:20+00:00 2026-06-07T08:45:20+00:00

I can connect to my VPN perfectly through the Windows GUI RasDial interface as

  • 0

I can connect to my VPN perfectly through the Windows GUI RasDial interface as well as it’s CLI equivalent (c:\windows\rasdial.exe). However, when attempting to automate it in C, RasDial returns 633: ERROR_PORT_NOT_AVAILABLE (source)

This is not specific to me. I have tested it on four different computers, each on separate internet connections.

Here is my source code:

#include <windows.h>
#include <winerror.h>
#include <Ras.h>
#include <raserror.h>
#include <wchar.h>
#include <stdio.h>

int EnumConnections();
int DialOut();
int HangUp();
int Debug();

int main()
{
    printf("Dial out return code: %d\n", DialOut());
    printf("Debug status: %i\n", Debug());
    EnumConnections();
    HangUp();
    return 0;
}

int EnumConnections()
{
    DWORD dwCb = 0;
    DWORD dwRet = ERROR_SUCCESS;
    DWORD dwConnections = 0;
    LPRASCONN lpRasConn = NULL;
    if (dwRet == ERROR_BUFFER_TOO_SMALL)
    {

        lpRasConn = (LPRASCONN) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwCb);
        if (lpRasConn == NULL){
            wprintf(L"HeapAlloc failed!\n");
            return 0;
        }

        lpRasConn[0].dwSize = sizeof(RASCONN);

        dwRet = RasEnumConnections(lpRasConn, &dwCb, &dwConnections);

        if (ERROR_SUCCESS == dwRet){
            wprintf(L"The following RAS connections are currently active:\n");
            DWORD i;
            for (i = 0; i < dwConnections; i++){
                         wprintf(L"%s\n", lpRasConn[i].szEntryName);
                  }
        }

        HeapFree(GetProcessHeap(), 0, lpRasConn);
        lpRasConn = NULL;
    }

    if(dwConnections >= 1)
        wprintf(L"The operation failed to acquire the buffer size.\n");

    else
        wprintf(L"There are no active RAS connections.\n");

    return 0;
}

int DialOut()
{
    LPCTSTR pbkLoc = "C:\\rasphone.pbk\0";
    char* szPhoneNumberToDial = "127.0.0.1";
    char* szUserName = "test\0";
    char* szPassword = "test\0";
    RASDIALPARAMS rdParams;
    rdParams.dwSize = sizeof(RASDIALPARAMS);
    rdParams.szEntryName[0] = '\0';
    lstrcpy(rdParams.szPhoneNumber, szPhoneNumberToDial);
    rdParams.szCallbackNumber[0] = '\0';
    lstrcpy( rdParams.szUserName, szUserName );
    lstrcpy( rdParams.szPassword, szPassword );
    rdParams.szDomain[0] = '\0';

    HRASCONN hRasConn = NULL;
    return RasDial(NULL, pbkLoc, &rdParams, 0L, NULL, &hRasConn);
}

int HangUp()
{
    printf("Hung up\n");
    HRASCONN hRasConn = NULL;
    return RasHangUp(hRasConn);
}

int Debug()
{
    RASCONNSTATUS RasConnStatus;
    HRASCONN hRasConn = NULL;
    RasConnStatus.dwSize = sizeof(RasConnStatus);
    return RasGetConnectStatus(hRasConn,&RasConnStatus);
}

Any ideas? I’m really stuck here. I read ALL of the RasDial documentation. I still have no idea where to start.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:45:21+00:00Added an answer on June 7, 2026 at 8:45 am

    For connecting to VPN connections you must have an entry contained within a phonebook. RasDial can only connect to dial-up connections if no entry has been provided. How else would it know whether to use PPTP, L2TP, SSTP, etc?

    Based on your above example, the entry name you’re providing for the entry is a null terminated string with no entry name. You’d need to create an entry with all your VPN connection information in “C:\rasphone.pbk” according to your example and pass the entry name to your struct in the szEntryName field.

    LPCTSTR entryName = "Your Entry Name\0";
    rdParams.szEntryName = entryName;
    

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way I can connect to a remote SQL server with Windows
I'm using web deploy to a remote server, through which we can only connect
I have a Windows Service that must connect, via VPN, to the network in
I can connect to VPN and I can access Sql Server using RDP. Now,
i have one application who use to connect to server via VPN. i can
I have successfully started a vncserver and can connect to it through the browser
I can connect with the DataContext to the Oracle database however I get errors
I can connect to my mysql db using php without a password fine. However,
How can connect iPhones, so that when a function is called on one iPhone,
i can connect mysql with java using eclipse in a java application with these

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.