109 #ifndef _UTILSOCKET_H_
110 #define _UTILSOCKET_H_
111 #ifdef _MSC_VER // Microsoft compiler
120 #include <arpa/inet.h>
121 #include <sys/socket.h>
128 #include <sys/types.h>
137 #define HEADER_LENGTH 54 // =10 + 4*(10+1);
158 int save_append(
char* *buffer,
const char *toAdd,
int *bufLen);
174 int nDbl,
int nInt,
int nBoo,
176 double dblVal[],
int intVal[],
int booVal[],
177 char* *buffer,
int *bufLen);
217 char **endptr,
const int base,
218 int *fla,
int *nDbl,
int *nInt,
int *nBoo);
234 int *nDbl,
int *nInt,
int *nBoo,
236 double dblVal[],
int intVal[],
int booVal[]);
253 int getsockethost(
const char *
const docname,
char *
const hostname);
291 const int *
nDblWri,
const int *nIntWri,
const int *nBooWri,
293 double dblValWri[],
int intValWri[],
int booValWri[]);
359 int *nDblRea,
int *nIntRea,
int *nBooRea,
361 double dblValRea[],
int intValRea[],
int booValRea[]);
373 char *buffer,
int *bufLen);
399 const int *flaWri,
int *
flaRea,
400 const int *
nDblWri,
const int *nIntWri,
const int *nBooWri,
401 int *nDblRea,
int *nIntRea,
int *nBooRea,
403 double dblValWri[],
int intValWri[],
int booValWri[],
405 double dblValRea[],
int intValRea[],
int booValRea[]);
423 const int *flaWri,
int *
flaRea,
450 const int *flaWri,
int *
flaRea,
457 const int *flaExport);
int assembleBuffer(int flag, int nDbl, int nInt, int nBoo, double curSimTim, double dblVal[], int intVal[], int booVal[], char **buffer, int *bufLen)
Assembles the buffer that will be exchanged through the IPC.
int disassembleHeaderBuffer(const char *buffer, char **endptr, const int base, int *fla, int *nDbl, int *nInt, int *nBoo)
Disassembles the header of the buffer that has been received through the IPC.
int getrequiredbufferlength(const int nDbl, const int nInt, const int nBoo)
Returns the required socket buffer length.
int REQUIRED_WRITE_LENGTH
int readbufferfromsocket(const int *sockfd, char *buffer, int *bufLen)
Reads a character buffer from the socket.
int exchangedoubleswithsocket(const int *sockfd, const int *flaWri, int *flaRea, const int *nDblWri, int *nDblRea, double *simTimWri, double dblValWri[], double *simTimRea, double dblValRea[])
Exchanges data with the socket.
int save_append(char **buffer, const char *toAdd, int *bufLen)
Appends a character array to another character array.
int exchangewithsocket(const int *sockfd, const int *flaWri, int *flaRea, const int *nDblWri, const int *nIntWri, const int *nBooWri, int *nDblRea, int *nIntRea, int *nBooRea, double *simTimWri, double dblValWri[], int intValWri[], int booValWri[], double *simTimRea, double dblValRea[], int intValRea[], int booValRea[])
Exchanges data with the socket.
int closeipc(int *sockfd)
Closes the inter process communication socket.
int SERVER_VERSION
This will be overwritten to contain the version number of the server.
int disassembleBuffer(const char *buffer, int *fla, int *nDbl, int *nInt, int *nBoo, double *curSimTim, double dblVal[], int intVal[], int booVal[])
Disassembles the buffer that has been received through the IPC.
Define statements used by the BCVTB C methods.
int writetosocket(const int *sockfd, const int *flaWri, const int *nDblWri, const int *nIntWri, const int *nBooWri, double *curSimTim, double dblValWri[], int intValWri[], int booValWri[])
Writes data to the socket.
end Get return values from pointers flaRea
int sendclienterror(const int *sockfd, const int *flaWri)
Writes an error flag to the socket stream.
int getIntCheckError(const char *nptr, char **endptr, const int base, int *val)
Gets an integer and does the required error checking.
int sendclientmessage(const int *sockfd, const int *flaWri)
Writes a message flag to the socket stream.
int getsockethost(const char *const docname, char *const hostname)
Gets the hostname for the BSD socket communication.
int getsocketportnumber(const char *const docname)
Gets the port number for the BSD socket communication.
int getDoubleCheckError(const char *nptr, char **endptr, double *val)
Gets a double and does the required error checking.
int readfromsocket(const int *sockfd, int *flaRea, int *nDblRea, int *nIntRea, int *nBooRea, double *curSimTim, double dblValRea[], int intValRea[], int booValRea[])
Reads data from the socket.
int exchangedoubleswithsocketFMU(const int *sockfd, const int *flaWri, int *flaRea, const int *nDblWri, int *nDblRea, double *simTimWri, double dblValWri[], double *simTimRea, double dblValRea[], const int *flaExport)
Exchanges data with the socket.
int getmainversionnumber()
Returns the main version number of the client.
int getRequiredReadBufferLength(const int *sockfd)
Returns the required socket buffer length by reading from the socket how many data it contains...
int establishclientsocket(const char *const docname)
Establishes a connection to the socket.