( Index )
Month
 

Brief Information about the May '12 CSIG Meeting

Internet Speedtest Using Multiple Threads by B. Arnold

Microsoft C++ and Visual Studio

Welcome to the CSIG, a Special Interest Group of the ACGNJ. We will be discussing Windows Programming using Visual C++  from Microsoft.

Microsoft Web Site  (Data Plotted in Excel)

Microsoft Web Site 

For this month we will continue with the project started last month. This time we will discuss background operation with multiple threads. This takes us into a universe that includes INTERUPTS and SIGNALS from the old days of Microprocessor and Computer Programming. However, this time it will be more modern and will utilize the features of the Microsoft DOT NET run time package that is normally used for Windows programming but which is equally at home in text based programming. The second screen image above shows the results of this new code. As the program runs, you can watch the "Progress in percent" go from 0 to 100 and show the corresponding speed.
Some information about the project follows.

It's a text based .Net program that accesses a data file located somewhere on the Internet!  (It also works on an Intranet or local network but that's not as exciting.) For example, lets say that you know about a particular data file on a Website in Spain. This program will download 1,000,000 bytes from that file and then calculate the download speed in KBytes per Second. The data file for the above Excel chart was created by attaching the program to the Microsoft Scheduler and running the program every 5 minutes. It adds to a data file every time that it runs. See the description in the sample code below for a more detailed introduction.

Again, let me welcome you to the CSIG, a Special Interest Group of the ACGNJ. Members and visitors are encouraged to bring in C++ questions, problems, and even programs to be discussed by the entire group. Most of the programs previously presented used the latest C++ compiler in Microsoft's Visual Studio. The compiler uses a concept called CLI. Here's what Wikipedia says:

The Common Language Infrastructure (CLI) is an open specification developed by Microsoft that describes the executable code and runtime environment that form the core of the Microsoft .NET Framework. The specification defines an environment that allows multiple high-level languages to be used on different computer platforms without being rewritten for specific architectures.

Windows Programming with Microsoft Managed code
Microsoft Visual Studio 2008, etc.
CLR Console Application
Debugging
Windows Task Scheduler
Text, Console, and File I/O
OOP - Object Oriented Programming
WebClient and StreamReader Classes

This is an exciting time for the C Language programming since Microsoft now has 4 different language compilers: C++, C++ Express, C-Sharp, and C-Sharp Express. These are all capable of creating Windows (tm) programs and the "Express" versions are free ! I see also that Microsoft is advertising a still newer version, Visual Studio 2010. Additionally, there are other companies making free and almost free compilers. Here's a link with many compilers: http://www.willus.com/ccomp.shtml

Microsoft .NET Framework

This is a large package, over 24 Megs. Most people running updated versions of Windows will already have it on their computer. If not, it may be downloaded from Microsoft.

Here's the download address for the Microsoft Framework:
Microsoft Software
Or, just look for: Microsoft .NET Framework Version x.x Redistributable Package (x86)

There are a number of ways to refer to this compiler and code.

The beginning of the evening (starting at 7:30pm) will be a RANDOM ACCESS discussion. The main presentation will discuss the program.

Our download site has code and programs from most of our meetings. ( Source Code Files )

Sample Code -

Sample Code
===========

// Speedtest.cpp : main project file.

//Speedtest.cpp B.Arnold 10-April-2012
//
//Object: To download a test file from the Internet and measure
// the time it takes. There are several specifications:
// 1. The file should be exactly 1,000,000 bytes.
// 2. It should be located on a server on the Internet.
// 3. The program will be launched with Windows's scheduler every 5 minutes.
// 4. A log file will be maintained with the speed values.
// Date and Time, Speed in Kilobytes/second.
// 5. Optionally, a 1,000,000 byte data file may be created.
// 6. The command line will be like: Speedtest http://www.abc.def/Speedtest.dat .


#include "stdafx.h"

#using <System.dll>

using namespace System;
using namespace System::Net;
using namespace System::IO;

int ProcessURI( String ^iName );
int Process( String ^iName );
void UpdateLog( String ^LogName, DateTime st, double rate );

int main(array<System::String ^> ^args)
{
int retcode = 0;
Console::WriteLine("Speedtest version 1.00 by B.Arnold - April 17, 2012");
if (args->Length == 0)
	{
	Console::WriteLine("Usage: Speedtest [MAKEDATA] [http://www.abc.def/Speedtest.dat]");
	Console::WriteLine("Usage: (For local networks) Speedtest \\\\192.168.1.40\\Downloads\\Speedtest.dat]");
	Console::ReadLine();
	return 0;
	}

if (args[0] == "MAKEDATA")
	{
	for (int i=0; i<1000; i++)
	for(int j=0; j<50; j++)
	Console::Write("0123456789ABCDEFGHIJ");
	return 0;
	}

if (args[0]->ToLower()->Contains("http:"))
	retcode = ProcessURI( args[0]);
else
	retcode = Process( args[0]);
Console::WriteLine("Done");
Threading::Thread::Sleep(3000);
return retcode;
}

// ===========



"Random Access" questions start at 7:30 Tuesday night.

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page