XrdNetMsg.hh

Go to the documentation of this file.
00001 #ifndef __XRDNETMSG_H__
00002 #define __XRDNETMSG_H__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                          X r d N e t M s g . h h                           */
00006 /*                                                                            */
00007 /* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012 
00013 //         $Id: XrdNetMsg.hh 27487 2009-02-18 13:17:34Z ganis $
00014 
00015 #include <stdlib.h>
00016 #include <string.h>
00017 #ifndef WIN32
00018 #include <strings.h>
00019 #include <unistd.h>
00020 #include <netinet/in.h>
00021 #include <sys/socket.h>
00022 #else
00023 #include <Winsock2.h>
00024 #endif
00025 
00026 class XrdSysError;
00027 
00028 class XrdNetMsg
00029 {
00030 public:
00031 
00032 // Send() sends a message to a host. If a destination is not supplied then the
00033 //        default destination at construction time is used.
00034 //        It returns one of three values:
00035 //        <0 -> Message not sent due to error (e.g., iovec data > 4096 bytes)
00036 //        =0 -> Message send (well as defined by UDP)
00037 //        >0 -> Message not sent, timeout occured.
00038 //
00039 int           Send(const char *buff,          // The data to be send
00040                          int   blen=0,        // Length (strlen(buff) if zero)
00041                    const char *dest=0,        // Hostname to send UDP datagram
00042                          int   tmo=-1);       // Timeout in ms (-1 = none)
00043 
00044 int           Send(const struct  iovec iov[], // Remaining parms as above
00045                          int     iovcnt,      // Number of elements in iovec
00046                    const char   *dest=0,      // Hostname to send UDP datagram
00047                          int     tmo=-1);     // Timeout in ms (-1 = none)
00048 
00049                 XrdNetMsg(XrdSysError *erp, const char *dest=0);
00050                ~XrdNetMsg() {if (DestHN) free(DestHN);
00051                              if (DestIP) free(DestIP);
00052                             }
00053 
00054 protected:
00055 int OK2Send(int timeout, const char *dest);
00056 int retErr(int ecode, const char *dest);
00057 
00058 XrdSysError       *eDest;
00059 char              *DestHN;
00060 struct sockaddr   *DestIP;
00061 int                DestSZ;
00062 int                FD;
00063 };
00064 #endif

Generated on Tue Jul 5 14:46:43 2011 for ROOT_528-00b_version by  doxygen 1.5.1