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 /* This file is part of the XRootD software suite. */ 00013 /* */ 00014 /* XRootD is free software: you can redistribute it and/or modify it under */ 00015 /* the terms of the GNU Lesser General Public License as published by the */ 00016 /* Free Software Foundation, either version 3 of the License, or (at your */ 00017 /* option) any later version. */ 00018 /* */ 00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00021 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00022 /* License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU Lesser General Public License */ 00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00026 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00027 /* */ 00028 /* The copyright holder's institutional names and contributor's names may not */ 00029 /* be used to endorse or promote products derived from this software without */ 00030 /* specific prior written permission of the institution or contributor. */ 00031 /******************************************************************************/ 00032 00033 #include <stdlib.h> 00034 #include <string.h> 00035 #ifndef WIN32 00036 #include <strings.h> 00037 #include <unistd.h> 00038 #include <netinet/in.h> 00039 #include <sys/socket.h> 00040 #else 00041 #include <Winsock2.h> 00042 #endif 00043 00044 #include "XrdNet/XrdNetAddr.hh" 00045 00046 class XrdSysError; 00047 00048 class XrdNetMsg 00049 { 00050 public: 00051 00052 //------------------------------------------------------------------------------ 00065 //------------------------------------------------------------------------------ 00066 00067 int Send(const char *buff, // The data to be send 00068 int blen=0, // Length (strlen(buff) if zero) 00069 const char *dest=0, // Hostname to send UDP datagram 00070 int tmo=-1); // Timeout in ms (-1 = none) 00071 00072 //------------------------------------------------------------------------------ 00084 //------------------------------------------------------------------------------ 00085 00086 int Send(const struct iovec iov[], // Remaining parms as above 00087 int iovcnt, // Number of elements in iovec 00088 const char *dest=0, // Hostname to send UDP datagram 00089 int tmo=-1); // Timeout in ms (-1 = none) 00090 //------------------------------------------------------------------------------ 00100 //------------------------------------------------------------------------------ 00101 00102 XrdNetMsg(XrdSysError *erp, const char *dest=0, bool *aOK=0); 00103 00104 //------------------------------------------------------------------------------ 00106 //------------------------------------------------------------------------------ 00107 00108 ~XrdNetMsg() {if (FD >= 0) close(FD);} 00109 00110 protected: 00111 int OK2Send(int timeout, const char *dest); 00112 int retErr(int ecode, const char *theDest); 00113 int retErr(int ecode, XrdNetAddr *theDest); 00114 00115 XrdSysError *eDest; 00116 XrdNetAddr dfltDest; 00117 XrdNetAddr specDest; 00118 int destOK; 00119 int FD; 00120 }; 00121 #endif