EH Field Transfer library


The field transfer library (download)

Nick Rasmussen wrote the field transfer library. The field library implements a client/server model where a client is anything that receives data and a server sends data. A server can send to one or more clients. Communication is done over TCP/IP sockets. The library uses network byte order so that communciation can occur between models running on machines with different byte orders. The library is written in C and can so far only be inserted into other models written in C.

The server first sets up what fields it will be sending:

fDesc=createFieldDesc(1, "foo", 3000, 1, 1);

The first number is the number of fields to send. This is followed by 4 items for each field: the name in quotes, then the x,y, and z dimensions.

The next call sets up the Server.

fServer=createFieldServer(fDesc, port, 1);

The first argument is the group of data to send. In this case fDesc. Its possible to set up a second server which may send a different group of data to a second model. The second argument is the internet port on the local machine to serve the data on. The last argument is the number of clients which will connect. The program will block on this call until all clients have connected.

Meanwhile, the client will contain a call to connect to the server.

fClient=createFieldClient(host, port, 10)

"host" is a string containing the hostname the server is running on. "port" is the port that server is serving data on and "10" is the number of seconds to wait until trying to connect. The client assumes the server is awake so some delay time may be necessary. After this call, the structure fClient will contain info about the data the client will recieve. Its then possible to allocated memory to recieve the data:

field=(float *)malloc(fClient->fDesc->head->size)

Once this handshaking is out of the way, the models can proceed to send and recieve data with calls to the send and recieve functions:

on the Server: sendTimestep(fServer, field);

on the Client: recieveTimestep(fClient, field);

The field library and two sample programs, FieldServer.t.c and FieldClient.t.c are available by ftp. Configure scripts and makefiles are included in the distribution. To build, type "./configure" and then 'make tests'.

Back to the technical information page