Download CSC4C Programmer`s Manual
Transcript
1.2 Documentation Set
The complete set of documentation is provided in Adobe PDF format. This is the first manual
(CSC_4C.PDF) in the set.
CSC_4C Programmer’s Manual (CSC_4C.PDF)
CSC User’s Manual (CSC_USR.PDF)
CSC Reference Manual (CSC_REF.PDF)
The CSC_4C Programmer’s Manual (CSC_4C.PDF) 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.PDF) 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.PDF) contains details on each individual CSC function.
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
#include
#include
#include
<windows.h>
<stdio.h>
<stdlib.h>
"csc.h"
// connect to TCP server and read it's greeting message
int ConnectToServer(char *Server, int Port, char *Buffer, int BufLen)
{int Code;
int DataSock;
// the client connects to the server
DataSock = cscClient(Server, Port);
// error? (negative return codes are errors)
if(DataSock<0) return DataSock;
// wait (3 sec) for greeting message from server
if(cscAwaitData(DataSock, 3000))
{// read server's greeting message into Buffer[]
Code = cscGetData(DataSock, Buffer, BufLen);
if(Code<0) return Code;
// terminate server's text message with a NULL
Buffer[Code] = '\0';
// return (virtual) data socket
return DataSock;
}
// timed out
return CSC_CONNECT_TIMEOUT;
}
6