MarshallSoft

Client / Server

Communications

Programmer's Manual


(CSC_4C)


Version 4.0

March 26, 2007

(Revised April 4, 2007)

This software is provided as-is.
There are no warranties, expressed or implied.



Copyright (C) 2007
All rights reserved



MarshallSoft Computing, Inc.
Post Office Box 4543
Huntsville AL 35815


Voice : 1.256.881.4630

FAX : 1.256.880.0925

web : www.marshallsoft.com


MARSHALLSOFT is a registered trademark of MarshallSoft Computing.



TABLE OF CONTENTS


1 Introduction
1.1 Features
1.2 Documentation Set
1.3 Example Program
1.4 Installation
1.5 Uninstalling
1.6 Pricing
1.7 Updates
1.8 Keycode
2 CSC Library Overview
2.1 Dynamic Link Libraries
2.2 Using the CSC Library
2.3 Win32 STDCALL and DECLSPEC
2.4 Console Mode
2.5 Example Protocol
2.6 Static Linking
2.7 Calling CSC from C++
2.8 Adding CSC To Your Existing Program
2.9 Error Display
2.10 Explicitly Loading CSC32.DLL
3 Compiler Issues
3.1 Compiling Using an IDE
3.2 Command Line Tool Setup
3.3 Command Line Batch Files
3.4 Command Line Makefiles
4 Supported Compilers
4.1 Microsoft Visual C++
4.2 Microsoft Visual C++ .NET
4.3 Microsoft Visual C#
4.4 Borland C/C++
4.5 Turbo C/C++ for Windows
4.6 Borland C++ Builder
4.7 Watcom C/C++
4.8 Lcc-Win32 C/C++
5 Compiling Programs
5.1 Compiling CSC Source Code
5.2 Compiling Example Programs
6 Example Programs
7 Revision History

1 Introduction

The Client / Server Communications Library for C/C++ (CSC4C) is a component library of functions used to create server and client programs that can communicate with other client and server programs across any TCP/IP network such as the Internet or a private network (intranet or LAN [local area net]). CSC uses the standard Windows API (Application Programmer's Interface) for all communication calls.

CSC4C includes multiple C/C++ example programs demonstrating client/server protocols, including examples that connect to HTTP (web) and POP3 servers.

The Client / Server Communications Library for C/C++ (CSC4C) component library supports and has been tested with C/C++, Microsoft Visual C++, Visual C++ .NET, Visual C# .NET, Borland C/C++, Borland Turbo C++ for Windows, Borland C++ Builder, Watcom C/C++, and LCC-Win32 C compilers. CSC4C can also be used with most other C/C++ Windows compilers.

A Win32 DLL is provided. CSC4C runs under all versions of Windows (95/98/ME/2000/NT/XP/Vista). The Client / Server Communications Library SDK DLL (CSC32.DLL) can also be used from any language (Visual Basic, VB.NET, ACCESS, EXCEL, VBA, Borland Delphi, Visual FoxPro, COBOL, Xbase++, Visual dBase, etc.) capable of calling the Windows API.

This Client/Server Communications Programmer's Manual provides information needed to compile programs in a C/C++/C# environment.

When comparing the Client/Server Communications Library against our competition, note that:

  1. CSC4C is a standard Windows DLL (NOT an OCX or ActiveX control) and is much smaller than a comparable OCX or ActiveX control.
  2. CSC4C does NOT depend on ActiveX or Microsoft Foundation Class (MFC) libraries or similar "support" libraries.
  3. CSC is fully threadable.
  4. The CSC functions can be called from applications not capable of using controls.

For the latest version of the CSC software, see

http://www.marshallsoft.com/client-server-communication.htm

Our goal is to provide a robust communication component library that you and your customers can depend upon. A fully functional evaluation version is available. Contact us if you have any questions.

1.1 Features

Some of the many features of the Client/Server Communications Library are as follows:

CSC can be used to communicate with other CSC programs, or they can be used to communicate with other TCP programs such as DNS, POP3, SMTP, FTP, HTTP, etc.



A good selection of C/C++ (also Visual C++ .NET and C# .NET) example programs with full source code is included. Refer to Section 6 for more details on each of the example programs.

Legend:
      Con = Console mode.
      GUI = GUI mode.
      VC = VC 4 thru 6.
      VC/B/W/L = For VC 4 thru 6, Borland 5.0 thru 5.5, Watcom 11, LCC
      VCN = Visual C++ .NET
      C# = Visual C# .NET (C Sharp)

    antispam.c      Anti-spam client program (Con: VC/B/W/L)
    auth_c.c        Authenticating client program (Con: VC/B/W/L).
    auth_s.c        Authenticating server program (Con: VC/B/W/L).
    bcb_prj.cpp     Displays CSC version, build, & registrations (Borland C++ Builder)
    client.c        Client program (Con: VC/B/W/L).
    cscver.c        Displays CSC version, build, & registrations (Con: VC/B/W/L).
    download.c      Downloads a file from HTTP (web) sever (Con: VC/B/W/L)
    FileCli.c       File client connects to FileSrv to download files. (Con: VC/B/W/L).
    FileGet.c       Received files (Con: VC/B/W/L).
    FilePut.c       Transmits files (Con: VC/B/W/L).
    FileSrv.c       File server handles concurrent connections (Con: VC/B/W/L).
    hello.cpp       Uses C++ class wrapper to display version, build, etc. (VC).
    HellpCS.cs      Displays CSC version, build, and registrations screen (C#)
    List.c          Lists all TCP/IP addresses (Con: VC/B/W/L).
    Proxy.c         POP3 proxy program (Con: VC/B/W/L)
    server.c        Server program (Con: VC/B/W/L)
    server2.c       Server program. Handles concurrent connections (Con: VC/B/W/L).
    vc_client.cpp   Client program (Con: VCN).
    vc_server.cpp   Server program. Handles concurrent connections (Con: VCN).
    vc_vers.cpp     Displays CSC version, build, and registrations screen (VCN).
    vc_w_client.cpp Client program (GUI: VCN).
    vc_w_server.cpp Server program. Handles concurrent connections (GUI: VCN).
    vers.c          Displays CSC version, build, & registrations (GUI:     VC/B/W/L).
    w_client.c      Client program (GUI: VC/B/W/L).
    w_server.c      Server program. Handles concurrent connections (GUI: VC/B/W/L).

1.2 Documentation Set

The complete set of documentation consists of three manuals in three formats. This is the first manual (CSC_4C) in the set.

The CSC_4C Programmer's Manual is the language specific (C/C++) manual and provides information needed to install and compile example programs in a C/C++ environment.

The CSC User's Manual (CSC_USR) discusses language independent issues. Information on Client / Server protocols as well as technical support, purchasing and license information is provided in the manual.

The CSC Reference Manual (CSC_REF) contains details on each individual CSC function.

Each manual comes in three formats:

Use Microsoft Word or Microsoft WordPad to print the document files. Documentation is also provided online at http://www.marshallsoft.com/csc4c.htm

1.3 Example Program

The following example demonstrates some of the library functions.

     #include "csc.h"
     #include "keycode.h"
   
     static LPSTR HostName;
     static char Temp[256];
   
     void main(int argc, char *argv[])
     {int Code;
      int Version;
      int Build;
      // attach
      Code = cscAttach(1, (long)CSC_KEY_CODE);
      if(Code<0)
        {printf("ERROR %d: cannot attach\n", Code);
         exit(1);
        }
      // define diagnostics log file
      cscSetString(-1, CSC_SET_LOG_FILE, (LPSTR)"cscver.log");
      // display version and build
      Version = cscGetInteger(-1, CSC_GET_VERSION);
      Build = cscGetInteger(-1, CSC_GET_BUILD);
      printf("CSC Version: %1d.%1d.%1d Build %d\n",
        0x0f&(Version>>8),0x0f&(Version>>4),0x0f&Version,Build);
      Code = cscGetString(-1, CSC_GET_REGISTRATION, (LPSTR)Temp, 51);
      if(Code<0) printf("ERROR %d: Cannot get registration string\n", Code);
      else printf("Registration: %s\n", Temp);
      cscRelease();
     }

1.4 Installation

  1. Before installation of CSC4C, your Windows C/C++ compiler should already be installed on your system and tested. In particular, include command line tools when installing your compiler if you want to compile using command line makefiles. If you need help with makefiles, see MAKEFILE.TXT.

  2. Unzip CSC4C40.ZIP(demo version) or CSCxxxxx.ZIP (registered version; xxxxx is your Customer ID) using any Windows unzip program.

  3. Run the installation program SETUP.EXE that will install all CSC4C files. SETUP will also copy CSC32.DLL to your Windows directory. No Windows system files are modified. Note that no DLL registration is required.

All recent WIN32 C/C++ compilers support the "declspec" keyword. Microsoft Visual C++ (version 4.0 and up), Borland (version 5.0 and up), Watcom (version 11.0 and up), and LCC-Win32 compilers support the "declspec" keyword.

1.5 Uninstalling

Uninstalling CSC4C is very easy. CSC does not modify the registry. First, delete the CSC project directory created when installing CSC4C. Second, delete CSC32.DLL from your Windows directory, typically C:\WINDOWS for Windows 3.1/95/98/Me/XP and C:\WINNT for Windows NT/2000. That's it!

1.6 Pricing

A developer license for the Client/Server Communications Library can be purchased for $115 (or $195 with source code to the library DLL). Purchasing details can be found in Section 1.3, "How to Purchase", of the CSC User's Manual (CSC_USR). (http://www.marshallsoft.com/csc_usr.htm#Section_1.3)

Also see INVOICE.TXT or http://www.marshallsoft.com/order.htm

1.7 Updates

When you register CSC4C you will receive a registered DLL plus a license file (CSCxxxx.LIC) that can be used to update your registered DLL for a period of one year from purchase. Updates can be downloaded from

http://www.marshallsoft.com/oem.htm

After one year, your license must be updated if you want to be able to download updates. Your license can be updated for $30 if ordered within one year of the original purchase (or previous update). After one year, licenses can be updated for $55. Updates to the source code can be purchased for $50.

Note that the registered CSC32. DLL never expires.

1.8 Keycode

CSC32.DLL has a keycode encoded within it. Your keycode is a 9 or 10 digit decimal number (unless it is 0), and will be found in the file KEYCODE.H. The keycode for the evaluation version is 0. You will receive a new key code when registering. The KEYCODE is passed to cscAttach.

If you get an error message (value -74) when calling cscAttach, it means that the keycode in your application does not match the keycode in the DLL. After registering, it is best to remove the evaluation version of the CSC32. DLL from the Windows search.


2 Library Overview

2.1 Dynamic Link Libraries

The Client/Server Communications Library (CSC) is implemented as a Win32 dynamic link library (DLL). A DLL is characterized by the fact that it need not be loaded until required by an application program and that only one copy of the DLL is necessary regardless of the number of application programs that use it. Contrast this to the traditional static library that is bound to each and every application that uses it at link time.

An important advantage that DLL's have over other "popular" library formats such as VBX or OCX is that DLL's are callable by all Windows applications. Since DLL's are the building blocks of the Windows Operating System, they will not be replaced by a "newer technology".

2.2 Using the CSC Library

The Client/Server Communications Library for C/C++ has been tested on multiple computers running Windows 95/98/Me/XP/Vista and Windows NT/2000.

The CSC4C library has also been tested with several C/C++ compilers, including Microsoft Visual C++ (all versions including C++ .NET and C# .NET), Borland C/C++, Borland C++ Builder, Turbo C/C++ for Windows, and Watcom C/C++.

The SETUP installation program will copy the Lib's and DLL to your Windows directory. Refer to Section 1.4 "Installation".

2.3 Win32 STDCALL and DECLSPEC

CSC32 is compiled using the _stdcall and _declspec keywords. This means that CSC4C uses the same calling conventions and file naming conventions as the Win32 API. In particular, function names are NOT decorated. There are no leading underscores or trailing "@size" strings added to function names.

Microsoft Visual C++ users can look at the CSC32 function names using the dumpbin.exe executable:

dumpbin /exports csc32.dll

2.4 Console Mode

CSC functions can be called from Win32 console mode programs. A "console mode" program is a Windows 95/98/NT/2000/Me/XP/VISTA WIN32 command line program running in a command window. Although console mode programs look like DOS programs, they are WIN32 programs that have access to the Win32 API and the entire Windows address space. Programming using console mode programs reduces the complexity of using GUI code. All console mode programs can be converted to GUI mode by adding the necessary Windows interface code

2.5 Example Client/Server Protocol

A description of the protocol used by the example programs can be found in Section_2.7, "Example Protocol", in the CSC User's Manual (http://www.marshallsoft.com/csc_usr.htm#Section_2.7).

Also refer to PROTOCOL.TXT in the \APPS subdirectory.


2.6 Static Linking

The registered user can also statically link CSC32.OBJ with their application, rather than making calls to the DLL's. To create an application that links CSC32.OBJ statically:

  1. All application code that includes CSC.H must define STATIC_LIBRARY before including CSC.H
  2. Your application must link with WSOCK32 (for WIN32).

If using Microsoft Developer Studio, make these changes:

  1. To your project file: Do not add CSC32.LIB to your project file.
  2. To the settings: (See "Build Settings" or "Project/Settings") (2a) C/C++ Tab: Add STATIC_LIBRARY to "preprocessor definitions:". (2b) Link Tab: Add wsock32.lib and csc32.obj to "object/library modules:"
  3. Add #include "csc.h" to all source files that make calls to CSC functions.

Alternatively, CSC32.C can be edited so that it can be compiled and linked like any other program file. In order to do this, remove all code from CSC32.C (provided when the source code is purchased) from

#ifndef STATIC_LIBRARY

through the following

#endif

2.7 Calling CSC from Visual C++

Like Windows itself, CSC functions are coded in ANSI C, but CSC functions can be called directly from both ANSI C programs and from C++ programs.

CSC functions can also be called using the C++ class wrapper fcsc. Refer to HELLO.CPP for an example.

2.8 Adding CSC To Your Existing Program

In order to add CSC to your existing program, (1) add

#include "csc.h"

to your source code, (2) link with CSC32.LIB (for MSVC), CSC32BCB.LIB (Borland C/C++ and C++ Builder), CSC32.LIB (Watcom), or CSC32LCC (Win32/LCC), and recompile from source.

Refer also to Section 4.0 below.


2.9 Error Display

The error message text associated with CSC error codes can be displayed by calling cscErrorText.

     void DisplayError(int ErrCode, char *MsgPtr)
     {int Len;
      char ErrBuff[129];
      printf("ERROR %d: ", ErrCode);
      if(MsgPtr) printf("%s: ", MsgPtr);
      Len = cscErrorText(ErrCode, (char *)ErrBuff, 128);
      if(Len>0) printf("%s\n", ErrBuff);
      else printf("\n");
     }

2.10 Explicitly Loading CSC32.DLL

When an application program runs that makes calls to CSC32.DLL, the Windows operating system will locate CSC32.DLL by searching the directories as specified by the Windows search path. If the CSC32.DLL is placed in the \WINDOWS directory (or \WINNT for Windows NT/2000), it will always be found by Windows.

However, CSC32.DLL can also be loaded from a specified directory by using the GetProcAddress Win32 API function. For an example, refer to the LoadLib.c program.


3 Compiler Issues

CSC programs can be compiled using an IDE or command line compiler tools. The following sections provide general compiler information.

3.1 Compiling Using an IDE

All current windows compilers have an "Integrated Development Environment" (IDE) for building application programs in the Windows environment.

Note that not only do IDE's vary between the different compiler manufacturers, but they also vary from version to version for the same compiler.

3.1.1 Compiling Example Programs with an IDE

Most of the example programs can be compiled from your compiler's IDE. For Visual C/C++, "project makefiles" are used since they can be used by all versions of Microsoft Visual C++ (v4.0, v5.0, and v6.0). When opening the workspace, select "makefiles(.mak)" for the file type.

Alternatively, for Visual C++ v6.0, select "projects (.dsp)" for the file type.

3.1.2 Compiling New Projects with an IDE

All of the IDE's use the concept of a file hierarchy. For example, the CSCVER example program file hierarchy in the IDE (for 32-bit) should look like:

       CSCVER.EXE
          +++ CSCVER.C
          +++ CSC32.LIB
   

Replace CSC32.LIB with CSC32BCB.LIB if using Borland C++ Builder, and with CSC32LCC.LIB if using LCC-Win32.

The order of the files is not significant. Refer to Section 4 below for a particular IDE.

3.2 Command Line Tool Setup

Many software developers overlook the power of using command line compilers. There are a number of very significant advantages to using the command line version of your C/C++ compiler. Among these are:

If you want to compile from the command line, your command line compiler tools must be set up properly. Note that you have an option of installing the command line tools (or not) when your compiler is first installed. Refer to your compiler manufacturer's manual for details.

If necessary, you can increase the size of your environment table space by adding

SHELL=C:\COMMAND.COM /e:1024 /p

to CONFIG.SYS in C:\ and then rebooting. Yes, this works for all versions of Windows, including Windows NT, 2000, and XP

For all compilers, your path should point to the compiler's BIN directory. For example, to add "C:\BC50\BIN" to your existing path, use

PATH C:\BC50\BIN;%PATH%

3.2.1 Microsoft

Set LIB and INCLUDE environment variables. For example,

SET INCLUDE=C:\MSVC\INCLUDE
SET LIB=C:\MSVC\LIB

3.2.2 Borland

Check that TURBOC.CFG, BCC32.CFG, TLINK.CFG, and TLINK32.CFG all have the correct information in them, as they should have when your compiler was installed. For example,

-IC:\BC5\INCLUDE
-LC:\BC5\LIB

BRCC (the Borland Resource Compiler) doesn't use the *.CFG files. Set the INCLUDE environment variable or BRCC will not be able to find the INCLUDE files (such as WINDOWS.H). For example,

SET INCLUDE=C:\BC5\INCLUDE

Clear the LIB environment variable (so it is not present when SET is typed at the command line) with

SET LIB=


3.2.3 Watcom

Set the WATCOM environment variables to point to your compilers include (H) and BIN directories. For example,

SET INCLUDE=C:\WC11\H;C:\WC11\H\NT
SET WATCOM=C:\WC11
SET EDPATH=C:\WC11\EDDAT
SET WWINHELP=E:\BINW

3.2.4 LCC-Win32

The LCC environment variables are set like the others. For example,

SET INCLUDE=C:\LCC\INCLUDE
SET LIB=C:\LCC\LIB

After making the above changes for your compiler, type PATH at the command line prompt to verify the search path, and type SET at the command line prompt to verify the INCLUDE and LIB environment variables.

3.3 Command Line Batch Files

If your compiler installation includes command line tools, then all of the example programs can be compiled directly from the command line. These same compiler commands can also be placed in a batch file.

See CSCVER$.BAT for an example of a command line batch file for LCC-Win32. Similarly, command line batch files can be created for all of the example programs.

3.4 Command Line Makefiles

Command line makefiles originated on UNIX systems. They are the standard way that C/C++ programs are constructed in command line environments. The advantage of makefiles (as compared to an integrated development environment) is that all compiler switches are always coded within the makefile and the makefile can be run with a single keystroke.

Command line makefiles are provided for Microsoft, Borland, Watcom, and LCC-Win32 command line compilers. They can be found in the \APPS sub-directory created when SETUP was run

     borland50.zip     Borland C/C++ 5.0 makefiles.
     borland55.zip     Borland C/C++ 5.5 makefiles.
     c-builder.zip     Borland C++ Builder project makefiles.
     lcc-win32.zip     LCC-WIN32 project command files.
     microsoft60.zip   Microsoft C/C++ (v1.52, v4.0, v5.0, v6.0) makefiles.
     watcom11.zip      Watcom C/C++ 11 makefiles.

4.0 Supported Compilers

The Client/Server Communications Library for C/C++ has been tested with Microsoft Visual C++ (all versions including Visual C++ .Net and Visual C# .NET), Borland C/C++, Borland C++ Builder, Borland Turbo C/C++, Watcom C/C++, and Lcc-Win32. Other Windows C/C++ compilers may work as well. Refer also to Section 5, "Compiling Example Programs".

4.1 Microsoft Visual C++ (all versions)

Microsoft Visual C++ programs can be compiled from either the command line or from within the Microsoft development environment. All MSVC programs are Win32 only.

4.1.1 Microsoft Command Line Makefiles

Programs can be compiled using command line makefiles. All Microsoft Win32 command line makefiles end with '"_m_". To compile using a makefile, use the Microsoft NMAKE utility. For example,

NMAKE -f SERVER._M_

CSC can be used with Microsoft Foundation Class (MFC) programs.

The file MICROSOFT60.ZIP contains the Microsoft Visual C++ (v4.0, v5.0, v6.0) command line makefiles.

4.1.2 Microsoft Developer Studio (VC v4.0)

To open an existing project, choose "File", then "Open Workspace", and then select "makefiles" from the list of file types. Most of the example programs have Microsoft Developer C/C++ project makefiles, ending with ".MAK" , such as CSCVER.MAK

To create a new project in MSVC v4.0, choose "File", then "New", then "Project Workspace". Select "Application" or "Console Application" for "Type:" and your project name for "Name:". Choose Win32 for platform. Then select "Create". Select "Insert", then "Files into Project". Add all filenames including any resource file (.RC) and CSC32.LIB. Lastly, select "Build", then "Rebuild All". Be sure to specify /YX rather than /Yu in your project settings [Build, Settings..., C/C++].

4.1.3 Microsoft Visual Studio (VC v5.0)

To open an existing project, choose "File", then "Open Workspace", and then select "makefiles" from the list of file types. Most of the example programs have Microsoft Developer C/C++ project makefiles, ending with ".MAK" , such as CSCVER.MAK.

To create a new project in MSVC v5.0, choose "File", then "New", then "Win32 Application" or "Win32 Console Application " and your project name. Check "Create new workspace". Select "Project", then "Add to Project". Add all filenames including any resource file (.RC) and CSC32.LIB. Lastly, select "Rebuild All".

If the compiler complains that it cannot find "_main", "Console Application" was chosen but the program being compiled is a GUI application. If the compiler complains that it cannot find "WinMain", "Application" was chosen but the program being compiled is a Console Mode application. Be sure to specify /YX rather than /Yu in your project settings [Build, Settings..., C/C++].

4.1.4 Microsoft Visual Studio (VC v6.0)

To open an existing project, follow the same directions as for MSVC v5.0, except that a DSP project file may be used instead of the MAK project makefile.

To create a new project in MSVC v6.0, follow the same directions as for MSVC v5.0 above.


4.2 Microsoft Visual C++ .NET

All Visual Studio C++ .Net projects end with extension ".vcproj". For example,

vc_vers.vcproj

In order to open an existing Visual C++ .Net project, choose "File", "Open", and then "Project" from the Visual Studio menu. Specify the directory containing the Visual C++ .Net project files (for example, C:\CSC4C\APPS).

In order to call CSC functions from Visual C++ .Net programs, do the following to your existing Visual C++ .Net project:

  1. Add
#include "csc.h"
#include "keycode.h"

after your existing #include statements.

  1. Open the project properties window under "Project" on the main menu. If your project is named "MyProject", then select "MyProject properties".

  2. Select "Configuration Properties", "Linker", "Input", "Additional Dependencies", then type in "CSC32.LIB" into the edit box. Note that CSC32.LIB must be in your project directory along with all of your source files.

  3. Rebuild.

NOTE: If using pre-compiled headers, the include statement

#include "stdafx.h"

must be the first include statement in your program.

4.3 Microsoft Visual C#

CSC functions can be called from Microsoft Visual C# (C-sharp) in the same manner as Win32 API functions.

All C# projects end with extension ".csproj". For example,

cs_vers.csproj
ClientCS.csproj

In order to open an existing C# project, choose "File", "Open", and then "Project" from the Microsoft C# Development Environment. Specify the directory containing the C# project files (for example, C:\CSC4C\APPS).

In order to call CSC functions from your existing C# programs, do the following to your C# source code:

  1. Add

using System.Runtime.InteropServices;

to your application source code.

  1. Add the contents of file csc_funs.cs to your application source code after

public class csc : System.Windows.Forms.Form

  1. Add the constants from csc_cons.cs to your program as they are needed.

Look at the cs_vers and ClientCS example projects in the APPS directory.

  1. Set "unsafe" compilation for any functions that calls CSC functions. For example

private unsafe void button1_Click(object sender, System.EventArgs e)

  1. Verify that AllowUnsafeBlocks is set to true in the project file (.vcproj). That is,

AllowUnsafeBlocks = "true"

Before writing your own C# programs, look at the HelloCS and ClientCS example projects.


4.4 Borland C/C++

Borland C/C++ version 5.0 programs can be compiled from either the command line (using makefiles ending with "._b_") or from within the Borland development environment using Borland v5.0 or above.

Borland C/C++ Version 5.5 (which can be downloaded from www.borland.com) is a free Win32 console mode compiler (no IDE). Makefiles for BC v5.5 end with "._i_", and (like Borland C++ Builder) use ILINK32 rather than TLINK32. Be careful with linker response files (*.RSP) -- they must NOT end with a carriage return / line feed!

Borland programs always link with CSC32BCB.LIB.

4.4.1 Borland Command Line Makefiles

Programs can be compiled using command line makefiles. All Borland Win32 command line makefiles end with "._b_" (or "._i_" for Borland 5.5). To compile using a makefile, use the Borland MAKE utility. For example,

MAKE -f CSCVER._B_

The file, BORLAND50.ZIP, contains the Borland C/C++ 5.0 command line makefiles, and
the file, BORLAND55.ZIP, contains the Borland C/C++ 5.5 command line makefiles.

4.4.2 Borland IDE

To create a new project, first turn off LINKER case sensitivities: Choose "Options", "Projects", "Linker", "General". Turn off the "case sensitive link" and "case sensitive exports and imports" boxes.

Next, choose "Files", then "New Project". Use the INS (Insert) key to pop up a dialog box into which the project file names are entered. Lastly, add CSC32BCB.LIB to your project. CSC32BCB.LIB can also be created from CSC32.DLL using the Borland IMPLIB utility:

IMPLIB CSC32BCB.LIB CSC32.DLL

Select "GUI" or "Console" for the "Target Model:". Only "Static" or "Dynamic" should be checked for "Standard Libraries:"

NOTE1: If, after linking in the IDE, you get unresolved external references to the library functions in which each function name is all upper case, then you have NOT turned off case sensitivity as described above.

NOTE2: If you get errors compiling the windows header file "WINDOWS.H", turn on "Borland Extensions" in "Options", "Project", "Compiler", "Source".

4.5 Borland Turbo C/C++ for Windows

Borland Turbo C/C++ for Windows does not have command line tools, so all programs must be compiled from the Turbo C/C++ integrated environment.

Follow the same directions as above (Borland IDE), except that the "Target Model:" can be any listed.

4.6 Borland C++ Builder

Borland C++ Builder does not have command line tools, so all programs must be compiled from the Borland C++ Builder integrated environment. Compile the BCB example program BCB_PRJ with BCB_PRJ.MAK if running BCB version 1 through 3, and compile with BCB_PRJ.BPR if running BCB version 4 or above.

To load the BCB_PRJ example project, Choose "File" / "Open Project" on the menu bar. Load BCB_PRJ.MAK (or BCB_PRJ.BPR). Then, choose "Build All" from "Project" to create the executable.

Note that CSC32BCB.LIB is the LIB file used with Borland C++ Builder. CSC32BCB .LIB can be created from CSC32.DLL by using the Borland IMPLIB program:

IMPLIB CSC32BCB.LIB CSC32.DLL

The file C-BUILDER.ZIP contains the Borland C++ Builder project makefiles.

4.7 Watcom C/C++

Watcom C/C++ programs can be compiled from either the command line or from within the Watcom development environment.

4.7.1 Watcom Command Line Makefiles

Win32 programs can be compiled using command line makefiles. All Watcom command line makefiles end with "._w_" for Win32 makefiles. To compile using a makefile, use the Watcom WMAKE utility. For example,

WMAKE -f CSCVER._W_

Win32 programs can also be compiled using command line batch files. See CSCVER$.BAT for an example of a console mode command line batch file and CSCVER$.BAT for an example of a GUI mode command line batch file. To run these command line batch files from the command line, type

CSCVER

The file, WATCOM11.ZIP, contains the Watcom C/C++ 11 command line makefiles.

4.7.2 Watcom IDE

To create a new project, choose "File", then "New Project". Enter the project name and then choose Win32 as the target. Use the INS (Insert) key to pop up a dialog box into which the project file names are entered.

Select "Options" from the main window, then "C Compiler Switches", then "10". Memory Models and Processor Switches". Check "80386 Stack based calling [-3s]", then check "32-bit Flat model [-mf]".

4.8 LCC-Win32 C/C++

Lcc-Win32 C/C++ programs can be compiled from either the command line or from within the development environment.

Lcc-Win32 is a freeware C compiler developed and distributed by Jacob Navia at

http://www.cs.virginia.edu/~lcc-win32/

To use our DLL's with Lcc-Win32, you must link with CSC32LCC.LIB. This file can also be re-created using the Lcc-Win32 utility BUILDLIB.

buildlib csc32.lcc csc32lcc.lib

Then, compile and link as normal. For example, to compile the CSCVER example program,

lcc -DWIN32 cscver.c
lcclnk cscver.obj csc32.lib -subsystem:console

To compile the GUI mode example VERS,

lcc -DWIN32 vers.c
lcc -DWIN32 paint.c
lrc vers.rc
lcclnk vers.obj paint.obj csc32lcc.lib vers.res -subsystem:windows

Command files are used for Lcc-Win32 rather than makefiles since the make utility that comes with LCC-Win32 does not work well (unlike the actual compiler).

The file, lcc-win32.zip, contains the LCC-WIN32 project command files.

5 Compiling Programs

5.1 Compiling CSC Source Code

This section applies only to those who have purchased source code for the Client/Server Communication SDK.

CSC32.DLL has been compiled using Microsoft Visual C++, and is callable from applications written using Microsoft, Borland, or Watcom compilers. If you recompile CSC32.C using Borland or Watcom compilers, then the resulting CSC32.DLL can only be used by applications compiled with the same compiler, unless the "_stdcall" and "_declspec" keywords are specified.

Microsoft Visual C++ is used to create CSC32.DLL and CSC32.OBJ (for static linking).

In order to create CSC32.DLL, type:

NMAKE -f CSC32._M_

In order to create CSC32.OBJ (for static linking) type

NMAKE -f CSC32S._M_

Alternatively, CSC32.C can be included in you project (along with MSC-VS.C and MSC-STR.C) like any other C file. Before compiling, define the symbol STATIC_LIBRARY.


5.2 Compiling Example Programs

The example programs can be compiled by using either the command line compiler or the compiler integrated development environment (IDE). Most compiler vendors provide both IDE and command line tools, although some compilers are command line only (Borland C/C++ 5.5 and LCC-Win32) or IDE only (Borland C/C++ Builder).

Refer also to Section 4, "Supported Compilers".

5.2.1 Compiling Using Visual C++ (VC v4.0, v5.0, and v6.0)

Microsoft Visual C/C++ (v4.0, v5.0, v6.0) compiles only 32-bit programs.

Programs can be compiled with Microsoft Visual C/C++ using either Developer Studio / Visual Studio or the command line compiler. Project makefiles (files ending in ".MAK") are provided for Developer Studio / Visual Studio. Command line makefiles (files ending in "._M_") are provided for use with the command line compiler (e.g.: NMAKE -f CSCVER._M_).

MSVC v6.0 project files (files ending in ".DSP") are also provided.

5.2.2 Compiling Using Visual C++ .Net

Microsoft Visual C/C++ .NET compiles only 32-bit programs.

Programs can be compiled with Microsoft Visual C/C++ .NET using either Visual Studio .NET or the command line compiler. Project files (files ending in ".VCPROJ") are provided for Visual Studio (e.g.: VC_VERS.VCPROJ).

Command line makefiles (files ending in "._M_") are provided for use with the Visual C++ .NET command line compiler (e.g.: NMAKE -f CSCVER._M_).

5.2.3 Compiling Using Visual C#

CSC functions can also be called from C# programs in the same manner in which Win32 API DLL functions are called.

5.2.4 Compiling Using Borland C/C++ 5.0

Borland C/C++ 5.0 can compile both 32-bit and 16-bit programs.

Programs can be compiled with Borland C/C++ using either the Borland IDE or the command line compiler. Several Project files (files ending in ".IDE") are provided for the Borland IDE (unzip BC50-IDE.ZIP)and command line makefiles (files ending in "._B_") for the Borland command line compiler. For example (MAKE -f CSCVER._B_)

5.2.5 Compiling Using Borland C/C++ 5.5

Borland C/C++ 5.5 is a command line compiler that can compile both 32-bit programs only. Command line makefiles (ending in "._I_") are provided For example (MAKE -f CSCVER._I_)

5.2.6 Compiling Using Borland C++ Builder

Borland C++ Builder (BCB) is an IDE that features "drag and drop" forms building (like Delphi and Visual Basic).

BCB compiles 32-bit programs only. Compile the BCB example program BCB_PRJ with BCB_PRJ.MAK if running BCB version 1 through 3, and compile with BCB_PRJ.BPR if running BCB version 4 or above.

The file C-BUILDER.ZIP contains the Borland C++ Builder project makefiles.

5.2.7 Compiling Using Watcom 11

Programs can be compiled with Watcom 11 using either the Watcom IDE or the command line compiler. Several command line makefiles (files ending in "._W_") for the Watcom command line compiler. For example (e.g.: WMAKE -f CSCVER._W_)

5.2.8 Compiling Using LCC-WIN32

LCC-Win32 compiles only 32-bit C (not C++) programs.

Command line batch files (ending with "$.bat) are provided for several of the projects. For example, to compile CSCVER using LCC-Win32, type CSCVER$.BAT on the command line.


6 Example Programs

Many of the example programs are written in Win32 console mode. This was done in order to provide the clearest possible code, without the complication and complexity of GUI code. All console mode programs can be converted to GUI mode by adding the necessary Windows interface code. Example programs are located in the APPS sub-directory. Refer to Section 4.0 for help with compiling and using makefiles.

Project files are classified as follows:

Microsoft Visual C/C++ Developer Studio files end in ".MAK" (or ".DSP" for v6.0) and can be loaded with "Open Workspace".

Other files ending with .MAK (and .BPR) include:

Please refer to the CSC User's Manual (CSC_USR.DOC or CSC_USR.HTM) for basic information on Server / Client protocols.

6.1 CSCVER

The first example program is the console mode program CSCVER (CSC Version) that displays the CSC library version number.

See the COMPILE comment in CSCVER.C for information on compiling.

6.2 VERS

VERS is a Windows (GUI mode) example C/C++ program that displays the CSC32.DLL Version, Build #, and registration string.

See the COMPILE comment in VERS.C for information on compiling.

6.3 VC_VERS

VC_VERS is a Visual C++ .Net Windows (GUI mode) example program that displays the CSC32.DLL Version, Build #, and registration string.

See the COMPILE comment in VC_VERS.CPP for information on compiling.

6.4 HELLO

HELLO is a console mode example C++ program that displays the CSC32.DLL Version, Build #, and registration string using the CSC class (fcsc.cpp).

See the COMPILE comment in HELLO.CPP for information on compiling.

6.5 CLIENT

CLIENT is a console mode example C/C++ program that operates as a client that connects to one of the example server programs.

Edit the lines following "*** PROGRAMMER" in CLIENT.C before compiling. See the COMPILE comment in CLIENT.C for information on compiling.

6.6 SERVER

SERVER is a console mode example C/C++ program that operates as a server that accepts connections from the example client program (CLIENT).

SERVER accepts a maximum of one connection at any one time. See SERVER2 for an example that can accept more than one connection at a time.

Edit the lines following "*** PROGRAMMER" in SERVER.C before compiling. See the COMPILE comment in SERVER.C for information on compiling.

6.7 SERVER2

SERVER2 is a console mode example C/C++ program that operates as a server that accepts connections from the example client program (CLIENT).

The SERVER2 program uses a state driver to keep track of the state of multiple connections concurrently.

Edit the lines following "*** PROGRAMMER" in SERVER2.C before compiling. See the COMPILE comment in SERVER2.C for information on compiling.

6.8 W_SERVER

W_SERVER is a GUI mode C/C++ server program that operates as a server that can accept connections from the example client program (CLIENT) which handles multiple concurrent connections.

Edit the lines following "*** PROGRAMMER" in W_SERVER.C before compiling. See the COMPILE comment in W_SERVER.C for information on compiling.

6.9 W_CLIENT

W_CLIENT is a GUI mode C/C++ client program that operates as a client that connects to one of the example server programs.

Edit the lines following "*** PROGRAMMER" in W_CLIENT.C before compiling. See the COMPILE comment in W_CLIENT.C for information on compiling.

6.10 FILEGET

FILEGET is a console mode C/C++ program that operates as a server, and receives files from the FILEPUT client.

Edit the lines following "*** PROGRAMMER" in FILEGET.C before compiling. See the COMPILE comment in FILEGET.C for information on compiling.


6.11 FILEPUT

FILEPUT is a console mode C/C++ program that operates as a client, and transmits files to the FILEGET server.

Edit the lines following "*** PROGRAMMER" in FILEPUT.C before compiling. See the COMPILE comment in FILEPUT.C for information on compiling.

6.12 AUTH_C

AUTH_C is a console mode C/C++ program that operates as a client implementing authenticated connections.

Edit the lines following "*** PROGRAMMER" in AUTH_C.C before compiling. See the COMPILE comment in AUTH_C.C for information on compiling.

6.13 AUTH_S

AUTH_S is a console mode C/C++ program that operates as a server implementing authenticated connections.

Edit the lines following "*** PROGRAMMER" in AUTH_S.C before compiling. See the COMPILE comment in AUTH_S.C for information on compiling.

6.14 LIST

LIST is a console mode C/C++ program that displays all NIC (Network Interface Card) addresses on a given machine.

See the COMPILE comment in LIST.C for information on compiling.

6.15 BCB_PRJ, BCB_PGM

BCB is a Borland C++ Builder Example program. Note that you must link with CSC32BCB.LIB rather than BCB32.LIB.

Load project file BCB_PRJ.BPR if running BCB version 4 or above, or BCB_PRJ.MAK if running BCB version 1 through 3.

6.16 HelloCS

HelloCS is the same as the Hello example program, except that it is written for Visual C#.

Load the project file HelloCS.csproj from the C# Development Environment.

6.17 VC_CLIENT

VC_CLIENT is an example console mode client program for Visual C++ .NET that connects to one of the example server programs.

Open workspace vc_client.vcproj in Visual Studio .NET

6.18 VC_SERVER

VC_SERVER is a example console mode server program for Visual C++ .NET which handles concurrent connections.

Edit the lines following "*** PROGRAMMER" in VC_SERVER.CPP before compiling. Open workspace vc_server.vcproj in Visual Studio .NET

6.19 VC_W_CLIENT

VC_W_CLIENT is an example GUI mode client program for Visual C++ .NET that connects to one of the example server programs.

Edit the lines following "*** PROGRAMMER" in VC_W_CLIENT.CPP before compiling. Open workspace vc_w_client.vcproj in Visual Studio .NET

6.20 VC_W_SERVER

VC_W_SERVER is an example GUI mode server program for Visual C++ .NET that handles concurrent connections.

Edit the lines following "*** PROGRAMMER" in VC_W_SERVER.CPP before compiling. Open workspace vc_w_server.vcproj in Visual Studio .NET

6.21 FileSrv ("File Server")

The FileSrv example server program can accept multiple connections and allows clients to download files. See the comments in FileSrv.c or see PROTOCOL.TXT for a description of the protocol used.

Edit the lines following "*** PROGRAMMER" in FileSrv.c before compiling. See the COMPILE comment in FileSrv.c for information on compiling.

6.22 FileCli ("File Client")

The FileCli example client program connects to the FileSrv example server program in order to download files. See the comments in FileCli.c or see PROTOCOL.TXT for a description of the protocol used.

Edit the lines following "*** PROGRAMMER" in FileCli.c before compiling. See the COMPILE comment in FileCli.c for information on compiling.

6.23 AntiSpam

AntiSpam is an example client program that connects to a POP3 server, downloads the headers from all of the email, then decides which of the email messages is spam and should be deleted.

The AntiSpam example program makes use of another MarshallSoft DLL product called the "Anti-Spam Toolkit" which facilitates using large data files of comparison strings. There is more information on AST in the AntiSpam.c example program. Also see the files AntiSpam.txt and AST_Funs.txt in the \DOCS directory.

Edit the lines following "*** PROGRAMMER" in AntiSpam.c before compiling. See the COMPILE comment in AntiSpam.c for information on compiling.

6.24 Download

Download is an example client that connects to the MarshallSoft web site (HTTP server) and downloads a zip-file from the web server.

Edit the lines following "*** PROGRAMMER" in Download.c before compiling. See the COMPILE comment in Download.c for information on compiling.

6.25 Proxy

Proxy is a POP3 proxy program. It is designed to accept connections from your POP3 email client and connect to your POP server, acting as a "go between" passing data in both directions.

The purpose of the Proxy example program is to demonstrate how to write proxy programs using CSC.

Edit the lines following "*** PROGRAMMER" in Proxy.c before compiling. See the COMPILE comment in Proxy.c for information on compiling.

6.26 ClientCS

ClientCS is an example GUI mode client program for Visual C# that connects to one of the example server programs. It is the C# version of vc_w_client.cpp.

Edit the lines following "*** PROGRAMMER" in ClientCS.cs before compiling. See the COMPILE comment in ClientCS.cs for information on compiling.


7 Revision History

Version 1.2: March 3, 2004.

Version 2.0: September 24, 2004.

Version 3.0: August 31, 2005.

Version 4.0: March 28, 2007