RSPlib Discussions

Text archives Help


Re: [RSPlib-Discusssion] Having trouble compiling applications


Chronological Thread 
  • From: Thomas Dreibholz <dreibh AT iem.uni-due.de>
  • To: rsplib-discussion AT sctp.de
  • Subject: Re: [RSPlib-Discusssion] Having trouble compiling applications
  • Date: Sat, 14 Mar 2009 14:29:00 +0100
  • List-archive: <http://lists.franken.de/pipermail/rsplib-discussion>
  • List-id: RSPlib Discussions <rsplib-discussion.sctp.de>
  • Organization: University of Duisburg-Essen, Institute for Experimental Mathematics

Dear Martin,

try the updated version 2.6.1~rc1 (Download from http://tdrwww.exp-math.uni-
essen.de/dreibholz/rserpool/#Download). It should fix the problem of the
missing include files and dependency on ext_socket.h.

For testing, also try the example source pe-example.c which I have attached
to
this mail. It is a PE for the Echo service. You can build it with: gcc pe-
example.c -o pe-example -O2 -Wall -lrsplib


Best regards
--
=======================================================================
Dr. Thomas Dreibholz

University of Duisburg-Essen, Room ES210
Inst. for Experimental Mathematics Ellernstraße 29
Computer Networking Technology Group D-45326 Essen/Germany
-----------------------------------------------------------------------
E-Mail:
dreibh AT iem.uni-due.de
Homepage: http://www.iem.uni-due.de/~dreibh
=======================================================================

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#include <math.h>
#include <sys/types.h>
#include <signal.h>

#include <rserpool/rserpool.h>
#include <rserpool/rserpool-internals.h>
#include <rserpool/tagitem.h>


int main(int argc, char** argv)
{
   const char*           poolHandle    = "EchoPool";
   unsigned int          reregInterval = 30000;
   struct rsp_info       info;
   struct rsp_loadinfo   loadInfo;
   struct rsp_sndrcvinfo rinfo;
   int                   flags;
   int                   fd;
   int                   i;

   memset(&loadInfo, 0, sizeof(loadInfo));
   loadInfo.rli_policy = PPT_ROUNDROBIN;

   for(i = 1;i < argc;i++) {
      if(rsp_initarg(&info, argv[i])) {
         /* rsplib argument */
      }
      else if(!(strncmp(argv[i], "-poolhandle=" ,12))) {
         poolHandle = (const char*)&argv[i][12];
      }
      else if(!(strncmp(argv[i], "-rereginterval=" ,15))) {
         reregInterval = atol((const char*)&argv[i][15]);
         if(reregInterval < 10) {
            reregInterval = 10;
         }
      }
      else {
         fprintf(stderr, "ERROR: Bad argument %s.\n", argv[i]);
         exit(1);
      }
   }


   if(rsp_initialize(&info) < 0) {
      fputs("ERROR: Unable to initialize rsplib Library!\n", stderr);
   }


   fd = rsp_socket(0, SOCK_SEQPACKET, IPPROTO_SCTP);
   if(fd >= 0) {
      if(rsp_listen(fd, 10) == 0) {
         if(rsp_register(fd, (const unsigned char*)poolHandle, strlen(poolHandle),
                        (const struct rsp_loadinfo*)&loadInfo, reregInterval, 0) == 0) {
            for(;;) {
               char buffer[65536];
               ssize_t received;
               ssize_t sent;
               flags = 0;
               received = rsp_recvfullmsg(fd, (char*)&buffer, sizeof(buffer),
                                          &rinfo, &flags, -1);
               if(received > 0) {
                  if(flags & MSG_RSERPOOL_NOTIFICATION) {
                     /* RSerPool notification */
                     printf("NOTIFICATION: ");
                     rsp_print_notification((const union rserpool_notification*)&buffer, stdout);
                     puts("");
                  }
                  else if(flags & MSG_RSERPOOL_COOKIE_ECHO) {
                     /* Cookie Echo */
                  }
                  else {
                     /* Regular data message -> echo it back */
                     printf("Echoing %d bytes\n", (int)received);
                     sent = rsp_sendmsg(fd, buffer, received, 0,
                                        rinfo.rinfo_session, rinfo.rinfo_ppid, rinfo.rinfo_stream,
                                        0, 0, 0);
                  }
               }
            }
         }
         else {
            fprintf(stderr, "ERROR: Failed to register PE to pool %s\n", poolHandle);
         }
      }
      rsp_close(fd);
   }
   else {
      fputs("ERROR: Failed to create RSerPool socket\n", stderr);
   }


   rsp_cleanup();
   return 0;
}

Attachment: signature.asc
Description: This is a digitally signed message part.




Archive powered by MHonArc 2.6.19+.

Top of page