00001 #ifndef __XRDNetWork_H__ 00002 #define __XRDNetWork_H__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d N e t W o r k . h h */ 00006 /* */ 00007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved. See XrdInfo.cc for complete License Terms */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC03-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 // $Id: XrdNetWork.hh 22437 2008-03-04 14:35:16Z rdm $ 00014 00015 #include <stdlib.h> 00016 #ifndef WIN32 00017 #include <strings.h> 00018 #include <unistd.h> 00019 #include <netinet/in.h> 00020 #include <sys/socket.h> 00021 #else 00022 #include <Winsock2.h> 00023 #endif 00024 00025 #include "XrdNet/XrdNet.hh" 00026 00027 class XrdSysError; 00028 class XrdNetLink; 00029 class XrdNetSecurity; 00030 00031 class XrdNetWork : public XrdNet 00032 { 00033 public: 00034 00035 // Accept() processes incomming connections. When a succesful connection is 00036 // made, it returns an XrdNetLink object suitable for communications. 00037 // If a timeout occurs, or an XrdNetLink object cannot be allocated, 00038 // it returns 0. Options are those defined above. A timeout, in 00039 // seconds, may be specified. 00040 // 00041 XrdNetLink *Accept(int opts=0, 00042 int timeout=-1); 00043 00044 // Connect() Creates a socket and connects to the given host and port. Upon 00045 // success, it returns an XrdNetLink object suitable for peer 00046 // communications. Upon failure it returns zero. Options are as above. 00047 // A second timeout may be specified. 00048 // 00049 XrdNetLink *Connect(const char *host, // Destination host or ip address 00050 int port, // Port number 00051 int opts=0, // Options 00052 int timeout=-1 // Second timeout 00053 ); 00054 00055 // Relay() creates a UDP socket and optionally sets things up so that 00056 // messages will be routed to a particular host:port destination. 00057 // Upon success it returs the address of a XrdNetLink object that 00058 // be used to communicate with the dest. Upon failure return zero. 00059 // 00060 XrdNetLink *Relay(const char *dest=0, // Optional destination 00061 int opts=0 // Optional options as above 00062 ); 00063 00064 // When creating this object, you must specify the error routing object. 00065 // Optionally, specify the security object to screen incomming connections. 00066 // (if zero, no screening is done). 00067 // 00068 XrdNetWork(XrdSysError *erp, XrdNetSecurity *secp=0) 00069 : XrdNet(erp, secp) {} 00070 ~XrdNetWork() {} 00071 }; 00072 #endif