xrootd
Loading...
Searching...
No Matches
XrdNet.hh
Go to the documentation of this file.
1#ifndef __XRDNET_H__
2#define __XRDNET_H__
3/******************************************************************************/
4/* */
5/* X r d N e t . h h */
6/* */
7/* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* Produced by Andrew Hanushevsky for Stanford University under contract */
9/* DE-AC02-76-SFO0515 with the Department of Energy */
10/* */
11/* This file is part of the XRootD software suite. */
12/* */
13/* XRootD is free software: you can redistribute it and/or modify it under */
14/* the terms of the GNU Lesser General Public License as published by the */
15/* Free Software Foundation, either version 3 of the License, or (at your */
16/* option) any later version. */
17/* */
18/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21/* License for more details. */
22/* */
23/* You should have received a copy of the GNU Lesser General Public License */
24/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26/* */
27/* The copyright holder's institutional names and contributor's names may not */
28/* be used to endorse or promote products derived from this software without */
29/* specific prior written permission of the institution or contributor. */
30/******************************************************************************/
31
32#include <cstdlib>
33#include <cstring>
34#ifndef WIN32
35#include <strings.h>
36#include <unistd.h>
37#include <netinet/in.h>
38#include <sys/socket.h>
39#else
40#include <Winsock2.h>
41#endif
42
43#include "XrdNet/XrdNetOpts.hh"
44
45class XrdNetAddr;
46class XrdNetBufferQ;
47class XrdNetPeer;
48class XrdNetSecurity;
49class XrdSysError;
50
51class XrdNet
52{
53public:
54
55//------------------------------------------------------------------------------
69//------------------------------------------------------------------------------
70
71int Accept(XrdNetAddr &myAddr,
72 int opts=0,
73 int timeout=-1);
74
75//------------------------------------------------------------------------------
93//------------------------------------------------------------------------------
94
95int Accept(XrdNetPeer &myPeer,
96 int opts=0,
97 int timeout=-1);
98
99//------------------------------------------------------------------------------
107//------------------------------------------------------------------------------
108
109int Bind( int port, // Port number
110 const char *contype="tcp" // "tcp" or "udp"
111 );
112
113//------------------------------------------------------------------------------
122//------------------------------------------------------------------------------
123
124int Bind( char *path, // Unix path < |109|
125 const char *contype="stream" // stream | datagram
126 );
127
128//------------------------------------------------------------------------------
146//------------------------------------------------------------------------------
147
148int Connect(XrdNetAddr &myAddr,
149 const char *dest, // Destination host or ip address
150 int port=-1, // Port number
151 int opts=0, // Options
152 int timeout=-1 // Second timeout
153 );
154
155//------------------------------------------------------------------------------
175//------------------------------------------------------------------------------
176
177int Connect(XrdNetPeer &myPeer,
178 const char *dest, // Destination host or ip address
179 int port=-1, // Port number
180 int opts=0, // Options
181 int timeout=-1 // Second timeout
182 );
183
184//------------------------------------------------------------------------------
189//------------------------------------------------------------------------------
190
191int Port() {return Portnum;}
192
193// Relay() creates a UDP socket and optionally decomposes a destination
194// of the form host:port. Upon success it fills in the Peer object
195// and return true (1). Upon failure, it returns false (0).
196//
197int Relay(XrdNetPeer &Peer, // Peer object to be initialized
198 const char *dest, // Optional destination
199 int opts=0 // Optional options as above
200 );
201
202int Relay(const char *dest); // Optional destination
203
204//------------------------------------------------------------------------------
210//------------------------------------------------------------------------------
211
212virtual void Secure(XrdNetSecurity *secp);
213
214//------------------------------------------------------------------------------
221//------------------------------------------------------------------------------
222
223void setDefaults(int options, int buffsz=0)
224 {netOpts = options; Windowsz = buffsz;}
225
226//------------------------------------------------------------------------------
231//------------------------------------------------------------------------------
232
233void setDomain(const char *dname)
234 {if (Domain) free(Domain);
235 Domain = strdup(dname);
236 Domlen = strlen(dname);
237 }
238
239//------------------------------------------------------------------------------
243//------------------------------------------------------------------------------
244
245void Trim(char *hname);
246
247//------------------------------------------------------------------------------
249//------------------------------------------------------------------------------
250
251void unBind();
252
253//------------------------------------------------------------------------------
259//------------------------------------------------------------------------------
260
261int WSize();
262
263//------------------------------------------------------------------------------
271//------------------------------------------------------------------------------
272
274
275//------------------------------------------------------------------------------
277//------------------------------------------------------------------------------
278
279virtual ~XrdNet();
280
281protected:
282
285char *Domain;
294
295private:
296
297int do_Accept_TCP(XrdNetAddr &myAddr, int opts);
298int do_Accept_TCP(XrdNetPeer &myPeer, int opts);
299int do_Accept_UDP(XrdNetPeer &myPeer, int opts);
300};
301#endif
Definition XrdNetAddr.hh:42
Definition XrdNetBuffer.hh:45
Definition XrdNetPeer.hh:39
Definition XrdNetSecurity.hh:44
Definition XrdNet.hh:52
char * Domain
Definition XrdNet.hh:285
int Windowsz
Definition XrdNet.hh:290
int Bind(int port, const char *contype="tcp")
int Relay(const char *dest)
int Connect(XrdNetPeer &myPeer, const char *dest, int port=-1, int opts=0, int timeout=-1)
XrdNet(XrdSysError *erp, XrdNetSecurity *secp=0)
int iofd
Definition XrdNet.hh:287
XrdSysError * eDest
Definition XrdNet.hh:283
XrdNetBufferQ * BuffQ
Definition XrdNet.hh:293
int Accept(XrdNetPeer &myPeer, int opts=0, int timeout=-1)
XrdNetSecurity * Police
Definition XrdNet.hh:284
int netOpts
Definition XrdNet.hh:291
void unBind()
Unbind the network from any bound resouces.
int do_Accept_UDP(XrdNetPeer &myPeer, int opts)
int Connect(XrdNetAddr &myAddr, const char *dest, int port=-1, int opts=0, int timeout=-1)
int Relay(XrdNetPeer &Peer, const char *dest, int opts=0)
int do_Accept_TCP(XrdNetAddr &myAddr, int opts)
int Domlen
Definition XrdNet.hh:286
int do_Accept_TCP(XrdNetPeer &myPeer, int opts)
int Portnum
Definition XrdNet.hh:288
virtual void Secure(XrdNetSecurity *secp)
int BuffSize
Definition XrdNet.hh:292
int Accept(XrdNetAddr &myAddr, int opts=0, int timeout=-1)
int WSize()
virtual ~XrdNet()
Destructor.
int Bind(char *path, const char *contype="stream")
int Port()
Definition XrdNet.hh:191
void setDomain(const char *dname)
Definition XrdNet.hh:233
int PortType
Definition XrdNet.hh:289
void Trim(char *hname)
void setDefaults(int options, int buffsz=0)
Definition XrdNet.hh:223
Definition XrdSysError.hh:90