COID - First Steps

WINDOWS

Installation


Compiling comm.lib

Before you start compiling a program, you have to build the comm library. Therefore open the comm.dsw with Visual C++. Before you build it, you have to check that under Project --> comm Properties --> C/C++ --> Code Generation the field 'Runtime Library ' is set to Multi-Threaded DLL.
Then you can build the release version of the project. Afterwards you can find comm.lib in the Release\ folder. Copy it to coid\comm\ and the installation is finished.

Creating the server-side files

Let's assume you already have a header file (example.h), containing the class you want to export (to export means to make it available as a service on a coid server). It's important that this file contains only one decorated (= meant to be exported) class. More about the decoration of the header file with keywords in the example document.

At first you have to run coidgen. In case you want to compile your server and client on different machines, just run coidgen once (on one machine!) and distribute the generated files afterwards. Open the console, change to your project directory and run (using the right coid directory):

    c:\program files\coid\bin\coidgen example.h

This generates the whole communication layer for the client and server from information found in that header, without modifying the class.
The output of coidgen is a set of files for the client (the directory 'client' is created for it) and for the server (is placed in the same directory as the service header). In our example it would generate example_dispatch.h, Makefile, client/example_client.cpp and client/example_client.h.

First create a empty Visual C++ project for the server side. Add the generated [service header file]_dispatch.cpp to your project, which is the server source file (Project --> Add existing Item --> _dispatch.cpp).
Then go to the project properties (Project --> Properties). In the C/C++ -> General section you have to enter the directory containing the coid directory (e.g. C:\program files) in the Additional Include Directory field.

Furthermore you have to check if under C/C++ --> Code Generation the field 'Runtime Library' is set to Multi-Threaded DLL.

Then you have to make the linker settings. First enter the full path of your coid/comm directory (e.g. c:\program files\coid\comm) into the Linker --> General --> 'Additional Libraries Directories' field.
Then modify the extension of Linker --> General --> 'Output' to .dev. At last set Linker -> Input -> 'Additional Dependencies' to comm.lib. Furthermore I had to set the Linker -> Input -> 'Ignore Specific Library' field to LIBCMT.lib.

Then you can build the release version of the project. Afterwards you can find your device (.dev) in the Release\ folder. Copy it to coid\bin\device in an appropriate subdirectory and the coid server will be loading it when starting.
Attention: Do not overwrite a currently used device! (Shut down server first)
Once the coid server has been started and has loaded the device file, the exported class can be called remotely from clients. Communication takes place over network or in case the server and client are on the same machine, coid uses interprocess communication.

For more information about coidgen read http://coid.sourceforge.net/web/gencoid.html

Creating the client-side files

Again create a empty Visual C++ project. As written above coidgen creates the client directory and puts a [service header file]_client.cpp and a [service header file]_client.h file in there, e.g. example_client.cpp and example_client.h. Add these files to your project (Project --> Add existing Item).
There has to be another source file (at least), which is calling the provided methods. This file is naturally not generated, but has to be written manually.
Then you have to change the project properties in the exact same way as above, except that the 'Runtime Library' is set to Multi-Threaded (not a DLL).
Now build your project and you get an .exe that you can run just like any other program. Just the coid server has to run (but not necessarily local).

The COID server

To start the coid server you just have start coid.exe, which can be found in the coid\bin\ directory.
In this case the server uses by default the port 55099, looks for the device files in coid\bin\device and is starting all services found in this files.
If you want to change these defaults, you will have to create a .devconf configuration file in coid\bin.

The .devconf file can contain these lines:
'port' PORT
'directory' NAME
'default' ('all' | 'none')
'service' NAME ('port' NUM)? ('dir' PATH)?
'!service' NAME

port        That's the server port the client has to connect to.
directory    In this directory (and subdirectories) the server looks for .dev files.
default     all (load all services) / none (just load services listed with service)
!service    do not load service NAME
service     load service NAME, optionally using an additional acceptor port (not coid acceptor port!) and working directory (not device directory!)

Once started, a 'tower' icon appears in the tray. Right click on it and and choose 'Cmd console -all'. In the console windows that opens, enter 'root' as user name and no password. There you will see a listing which services have been started. If your service (the name is your exported class) is listed, everything went well and you can start your client.

More services in one device

It is possible to link more than one service in a single device. Therefore just run coidgen for every service header file. Add all _dispatch.h files to your server project.
On the client side also add all _client files to your client project.