xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdNet
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 <stdlib.h>
33
#include <string.h>
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
45
class
XrdNetAddr;
46
class
XrdNetBufferQ;
47
class
XrdNetPeer;
48
class
XrdNetSecurity;
49
class
XrdSysError
;
50
51
class
XrdNet
52
{
53
public
:
54
55
//------------------------------------------------------------------------------
69
//------------------------------------------------------------------------------
70
71
int
Accept
(XrdNetAddr &myAddr,
72
int
opts=0,
73
int
timeout=-1);
74
75
//------------------------------------------------------------------------------
92
//------------------------------------------------------------------------------
93
94
int
Accept
(XrdNetPeer &myPeer,
95
int
opts=0,
96
int
timeout=-1);
97
98
//------------------------------------------------------------------------------
106
//------------------------------------------------------------------------------
107
108
int
Bind
(
int
port,
// Port number
109
const
char
*contype=
"tcp"
// "tcp" or "udp"
110
);
111
112
//------------------------------------------------------------------------------
121
//------------------------------------------------------------------------------
122
123
int
Bind
(
char
*path,
// Unix path < |109|
124
const
char
*contype=
"stream"
// stream | datagram
125
);
126
127
//------------------------------------------------------------------------------
145
//------------------------------------------------------------------------------
146
147
int
Connect
(XrdNetAddr &myAddr,
148
const
char
*dest,
// Destination host or ip address
149
int
port=-1,
// Port number
150
int
opts=0,
// Options
151
int
timeout=-1
// Second timeout
152
);
153
154
//------------------------------------------------------------------------------
174
//------------------------------------------------------------------------------
175
176
int
Connect
(XrdNetPeer &myPeer,
177
const
char
*dest,
// Destination host or ip address
178
int
port=-1,
// Port number
179
int
opts=0,
// Options
180
int
timeout=-1
// Second timeout
181
);
182
183
//------------------------------------------------------------------------------
188
//------------------------------------------------------------------------------
189
190
int
Port
() {
return
Portnum
;}
191
192
// Relay() creates a UDP socket and optionally decomposes a destination
193
// of the form host:port. Upon success it fills in the Peer object
194
// and return true (1). Upon failure, it returns false (0).
195
//
196
int
Relay
(XrdNetPeer &Peer,
// Peer object to be initialized
197
const
char
*dest,
// Optional destination
198
int
opts=0
// Optional options as above
199
);
200
201
int
Relay
(
const
char
*dest);
// Optional destination
202
203
//------------------------------------------------------------------------------
209
//------------------------------------------------------------------------------
210
211
virtual
void
Secure
(XrdNetSecurity *secp);
212
213
//------------------------------------------------------------------------------
220
//------------------------------------------------------------------------------
221
222
void
setDefaults
(
int
options,
int
buffsz=0)
223
{
netOpts
= options;
Windowsz
= buffsz;}
224
225
//------------------------------------------------------------------------------
230
//------------------------------------------------------------------------------
231
232
void
setDomain
(
const
char
*dname)
233
{
if
(
Domain
) free(
Domain
);
234
Domain
= strdup(dname);
235
Domlen
= strlen(dname);
236
}
237
238
//------------------------------------------------------------------------------
242
//------------------------------------------------------------------------------
243
244
void
Trim
(
char
*hname);
245
246
//------------------------------------------------------------------------------
248
//------------------------------------------------------------------------------
249
250
void
unBind
();
251
252
//------------------------------------------------------------------------------
258
//------------------------------------------------------------------------------
259
260
int
WSize
();
261
262
//------------------------------------------------------------------------------
270
//------------------------------------------------------------------------------
271
272
XrdNet
(
XrdSysError
*erp, XrdNetSecurity *secp=0);
273
274
//------------------------------------------------------------------------------
276
//------------------------------------------------------------------------------
277
278
virtual
~XrdNet
();
279
280
protected
:
281
282
XrdSysError
*
eDest
;
283
XrdNetSecurity *
Police
;
284
char
*
Domain
;
285
int
Domlen
;
286
int
iofd
;
287
int
Portnum
;
288
int
PortType
;
289
int
Windowsz
;
290
int
netOpts
;
291
int
BuffSize
;
292
XrdNetBufferQ *
BuffQ
;
293
294
private
:
295
296
int
do_Accept_TCP
(XrdNetAddr &myAddr,
int
opts);
297
int
do_Accept_TCP
(XrdNetPeer &myPeer,
int
opts);
298
int
do_Accept_UDP
(XrdNetPeer &myPeer,
int
opts);
299
};
300
#endif
Generated by
1.8.3.1