I'm a student developing an application which helps the user to check the internet connection speed on a set of dialup connections.
string[,] connections = new string[5, 2] { { "username", "password" }, { "username", "password" },{ "username", "password" },{ "username", "password" },{ "username", "password" } };
The connections are stored in an array as listed above , i'm seeking for the simplest approach to dial them and test the speed of each connection by downloading a file from a remote server. can the experts please be kind to help me out with a good solution ?
Thank you.
i've already tried DOTRas, i'm trying to use but can't exactly figure out how to make the connection.
RasEntry.CreateDialUpEntry
DotRas is a wrapper around the Windows RAS API which uses phonebook files to store the information how to connect to a remote RAS server, and then a command which actually dials the entry. The examples included with the SDK, while only demonstrating how to do a VPN connection, can have those same principles applied to a dial-up connection without a lot of effort. The only difference is calling CreateDialUpEntry instead of CreateVpnEntry when creating your entry.
Step 1: Create the Entry
You'll need to first create your entry and get it added to a phonebook so the dial operation can find it later:
string path = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.User);
using (RasPhoneBook pbk = new RasPhoneBook())
{
pbk.Open(path);
// Find the device that will be used to dial the connection.
RasDevice device = RasDevice.GetDevices().Where(o => o.Name == "Your Modem Name" && o.DeviceType == RasDeviceType.Modem).First();
RasEntry entry = RasEntry.CreateDialUpEntry("Your Entry", "5555551234", device);
// Configure any options for your entry here via entry.Options
pbk.Entries.Add(entry);
}
That will get a single entry named "Your Entry" and a phone number of "555-555-1234" into the phone book. Keep in mind, you will need to know the settings to configure on the entry to ensure the connection will succeed.
Step 2: Dial the Entry
using (RasDialer dialer = new RasDialer())
{
dialer.EntryName = "Your Entry";
dialer.PhoneBookPath = path;
dialer.Credentials = new NetworkCredential("User", "Password");
dialer.Dial();
}
That will establish the connection to "Your Entry" using the credentials specified.
Step 3: Disconnect the Entry
In order to disconnect you'll need to find the active connection and call HangUp on it.
RasConnection conn = RasConnection.GetActiveConnections().Where(o => o.Name == "Your Entry").First();
conn.HangUp();
I hope that answers your question!
Edit: I wanted to add, if the connections already exist on the machine that is being tested you can simply skip straight to step two and dial them.