User`s guide
Developing LUC Applications [5]
Then the client can be run multiple times using the following command:
% exluc -c id
Where id is the server endpoint ID printed to the command line when the server
starts.
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <netinet/in.h> // htonl/ntohl byte swapping
#include <luc/luc_exported.h>
// The service type is an application-specific major service id.
// It identifies the general type of service requested by the client.
// One server may implement one or more service types.
// For this example, one service type is defined.
int svc_type = 0;
// The function index is an application-specific minor service id.
// It identifies a specific server function out of the functions defined
// by the server within one of its supported service types.
// Each service type may implement one or more functions.
// For this example, one function within the svc_type service type is defined.
int reduce_func_idx = 0;
#define NREDUCE 10 // number of values to be summed
// Opteron uses little-endian byte order and XMT uses big-endian byte order.
// When an Opteron client uses an XMT server, byte swapping is required
// to convert the data between the two systems.
// This example uses network byte order (big-endian) for all LUC data transfers,
// and converts to host byte order before using LUC data.
#if defined(__MTA__) || defined(NO_BYTE_SWAP)
// Host byte order is the same as network byte order on XMT,
// so no conversion is necssary.
#define NetworkToHost(b,l)
#define HostToNetwork(b,l)
#else
// Byte swap to convert between host and network byte ordering.
void ByteSwap(void *buf, size_t len)
{
char *c = (char *) buf;
int i;
for (i=0;i < len;i+=2)
{
char t = c[0];
c[0] = c[1];
c[1] = t;
}
}
S–2479–20 61