xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdClient
XrdClientSock.hh
Go to the documentation of this file.
1
2
// //
3
// XrdClientSock //
4
// //
5
// Author: Fabrizio Furano (INFN Padova, 2004) //
6
// Adapted from TXNetFile (root.cern.ch) originally done by //
7
// Alvise Dorigo, Fabrizio Furano //
8
// INFN Padova, 2003 //
9
// //
10
// Client Socket with timeout features //
11
// //
12
// June 06 - Fabrizio Furano //
13
// The function prototypes allow specializations for multistream xfer //
14
// purposes. In this class only monostream xfers are allowed. //
15
// //
17
18
// $Id$
19
20
#ifndef XRC_SOCK_H
21
#define XRC_SOCK_H
22
23
#include <
XrdClient/XrdClientUrlInfo.hh
>
24
25
struct
XrdClientSockConnectParms
{
26
XrdClientUrlInfo
TcpHost
;
27
int
TcpWindowSize
;
28
};
29
30
class
XrdClientSock
{
31
public
:
32
typedef
int
Sockid
;
33
typedef
int
Sockdescr
;
34
35
friend
class
XrdClientPhyConnection
;
36
37
private
:
38
39
int
fSocket
;
40
41
protected
:
42
43
44
int
fRequestTimeout
;
45
XrdClientSockConnectParms
fHost
;
46
47
bool
fConnected
;
48
bool
fRDInterrupt
;
49
bool
fWRInterrupt
;
50
51
// Tells if we have to reinit the table of the fd selectors
52
// after adding or removing one of them
53
bool
fReinit_fd
;
54
55
virtual
int
SaveSocket
() {
int
fd =
fSocket
;
fSocket
= -1;
56
fConnected
= 0;
fRDInterrupt
= 0;
fWRInterrupt
= 0;
return
fd; }
57
58
void
SetInterrupt
(
int
which = 0) {
if
(which == 0 || which == 1)
fRDInterrupt
= 1;
59
if
(which == 0 || which == 2)
fWRInterrupt
= 1; }
60
61
// returns the socket descriptor or -1
62
int
TryConnect_low
(
bool
isUnix = 0,
int
altport = 0,
int
windowsz = 0);
63
64
// Send the buffer to the specified socket
65
virtual
int
SendRaw_sock
(
const
void
* buffer,
int
length,
Sockdescr
sock);
66
public
:
67
68
//--------------------------------------------------------------------------
75
//--------------------------------------------------------------------------
76
XrdClientSock
(
XrdClientUrlInfo
host,
int
windowsize = 0,
int
fd = -1 );
77
virtual
~XrdClientSock
();
78
79
virtual
void
BanSockDescr
(
Sockdescr
,
Sockid
) {}
80
virtual
void
UnBanSockDescr
(
Sockdescr
) { }
81
82
// Makes a pending recvraw to rebuild the list of interesting selectors
83
void
ReinitFDTable
() {
fReinit_fd
=
true
; }
84
85
// Gets length bytes from the specified substreamid
86
// If substreamid = 0 then use the main stream
87
// If substreamid = -1 then
88
// use any stream which has something pending
89
// and return its id in usedsubstreamid
90
// Note that in this base class only the multistream intf is provided
91
// but the implementation is monostream
92
virtual
int
RecvRaw
(
void
* buffer,
int
length,
Sockid
substreamid = -1,
93
Sockid
*usedsubstreamid = 0);
94
95
// Send the buffer to the specified substream
96
// if substreamid <= 0 then use the main one
97
virtual
int
SendRaw
(
const
void
* buffer,
int
length,
Sockid
substreamid = 0);
98
99
void
SetRequestTimeout
(
int
timeout = -1);
100
101
// Performs a SOCKS4 handshake in a given stream
102
// Returns the handshake result
103
// If successful, we are connected through a socks4 proxy
104
virtual
int
Socks4Handshake
(
Sockid
sockid);
105
106
virtual
void
TryConnect
(
bool
isUnix = 0);
107
108
// Returns a temporary socket id or -1
109
// The temporary given sock id is to be used to send the kxr_bind_request
110
// If all this goes ok, then the caller must call EstablishParallelSock, otherwise the
111
// creation of parallel streams should be aborted (but the already created streams are OK)
112
virtual
Sockdescr
TryConnectParallelSock
(
int
/*port*/
,
int
/*windowsz*/
,
Sockid
&
/*tmpid*/
) {
return
-1; }
113
114
// Attach the pending (and hidden) sock
115
// to the given substreamid
116
// the given substreamid could be an integer suggested by the server
117
virtual
int
EstablishParallelSock
(
Sockid
/*tmpsockid*/
,
Sockid
/*newsockid*/
) {
return
-1; }
118
119
virtual
int
RemoveParallelSock
(
Sockid
/* sockid */
) {
return
-1; };
120
121
// Suggests a sockid to be used for a req
122
virtual
Sockid
GetSockIdHint
(
int
/* reqsperstream */
) {
return
0; }
123
124
virtual
void
Disconnect
();
125
126
bool
IsConnected
() {
return
fConnected
;}
127
virtual
int
GetSockIdCount
() {
return
1; }
128
virtual
void
PauseSelectOnSubstream
(
Sockid
/* substreamid */
) { }
129
virtual
void
RestartSelectOnSubstream
(
Sockid
/*substreamid */
) { }
130
};
131
132
#endif
Generated by
1.8.1.2