00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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 XrdClientSock(XrdClientUrlInfo host, int windowsize = 0);
00069 virtual ~XrdClientSock();
00070
00071 virtual void BanSockDescr(Sockdescr, Sockid) {}
00072 virtual void UnBanSockDescr(Sockdescr) { }
00073
00074
00075 void ReinitFDTable() { fReinit_fd = true; }
00076
00077
00078
00079
00080
00081
00082
00083
00084 virtual int RecvRaw(void* buffer, int length, Sockid substreamid = -1,
00085 Sockid *usedsubstreamid = 0);
00086
00087
00088
00089 virtual int SendRaw(const void* buffer, int length, Sockid substreamid = 0);
00090
00091 void SetRequestTimeout(int timeout = -1);
00092
00093
00094
00095
00096 virtual int Socks4Handshake(Sockid sockid);
00097
00098 virtual void TryConnect(bool isUnix = 0);
00099
00100
00101
00102
00103
00104 virtual Sockdescr TryConnectParallelSock(int , int , Sockid &) { return -1; }
00105
00106
00107
00108
00109 virtual int EstablishParallelSock(Sockid , Sockid ) { return -1; }
00110
00111 virtual int RemoveParallelSock(Sockid ) { return -1; };
00112
00113
00114 virtual Sockid GetSockIdHint(int ) { return 0; }
00115
00116 virtual void Disconnect();
00117
00118 bool IsConnected() {return fConnected;}
00119 virtual int GetSockIdCount() { return 1; }
00120 virtual void PauseSelectOnSubstream(Sockid ) { }
00121 virtual void RestartSelectOnSubstream(Sockid ) { }
00122 };
00123
00124 #endif