00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00017
00018
00019
00020 #ifndef XRC_SOCK_H
00021 #define XRC_SOCK_H
00022
00023 #include <XrdClient/XrdClientUrlInfo.hh>
00024
00025 struct XrdClientSockConnectParms {
00026 XrdClientUrlInfo TcpHost;
00027 int TcpWindowSize;
00028 };
00029
00030 class XrdClientSock {
00031 public:
00032 typedef int Sockid;
00033 typedef int Sockdescr;
00034
00035 friend class XrdClientPhyConnection;
00036
00037 private:
00038
00039 int fSocket;
00040
00041 protected:
00042
00043
00044 int fRequestTimeout;
00045 XrdClientSockConnectParms fHost;
00046
00047 bool fConnected;
00048 bool fRDInterrupt;
00049 bool fWRInterrupt;
00050
00051
00052
00053 bool fReinit_fd;
00054
00055 virtual int SaveSocket() { int fd = fSocket; fSocket = -1;
00056 fConnected = 0; fRDInterrupt = 0; fWRInterrupt = 0; return fd; }
00057
00058 void SetInterrupt(int which = 0) { if (which == 0 || which == 1) fRDInterrupt = 1;
00059 if (which == 0 || which == 2) fWRInterrupt = 1; }
00060
00061
00062 int TryConnect_low(bool isUnix = 0, int altport = 0, int windowsz = 0);
00063
00064
00065 virtual int SendRaw_sock(const void* buffer, int length, Sockdescr sock);
00066 public:
00067
00068
00075
00076 XrdClientSock(XrdClientUrlInfo host, int windowsize = 0, int fd = -1 );
00077 virtual ~XrdClientSock();
00078
00079 virtual void BanSockDescr(Sockdescr, Sockid) {}
00080 virtual void UnBanSockDescr(Sockdescr) { }
00081
00082
00083 void ReinitFDTable() { fReinit_fd = true; }
00084
00085
00086
00087
00088
00089
00090
00091
00092 virtual int RecvRaw(void* buffer, int length, Sockid substreamid = -1,
00093 Sockid *usedsubstreamid = 0);
00094
00095
00096
00097 virtual int SendRaw(const void* buffer, int length, Sockid substreamid = 0);
00098
00099 void SetRequestTimeout(int timeout = -1);
00100
00101
00102
00103
00104 virtual int Socks4Handshake(Sockid sockid);
00105
00106 virtual void TryConnect(bool isUnix = 0);
00107
00108
00109
00110
00111
00112 virtual Sockdescr TryConnectParallelSock(int , int , Sockid &) { return -1; }
00113
00114
00115
00116
00117 virtual int EstablishParallelSock(Sockid , Sockid ) { return -1; }
00118
00119 virtual int RemoveParallelSock(Sockid ) { return -1; };
00120
00121
00122 virtual Sockid GetSockIdHint(int ) { return 0; }
00123
00124 virtual void Disconnect();
00125
00126 bool IsConnected() {return fConnected;}
00127 virtual int GetSockIdCount() { return 1; }
00128 virtual void PauseSelectOnSubstream(Sockid ) { }
00129 virtual void RestartSelectOnSubstream(Sockid ) { }
00130 };
00131
00132 #endif