jsmartsock.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef JSMARTSOCK_HPP
  14. #define JSMARTSOCK_HPP
  15. #include "jsocket.hpp"
  16. interface jlib_decl ISmartSocket : extends IInterface
  17. {
  18. // unique to ISmartSocket
  19. virtual ISocket *querySocket() = 0;
  20. // subset of ISocket
  21. virtual void read(void* buf, size32_t min_size, size32_t max_size, size32_t &size_read,
  22. unsigned timeoutsecs = WAIT_FOREVER) = 0;
  23. virtual void read(void* buf, size32_t size)=0;
  24. virtual size32_t write(void const* buf, size32_t size) = 0;
  25. virtual void close() = 0;
  26. };
  27. interface jlib_decl ISmartSocketFactory : extends IInterface
  28. {
  29. virtual int run()=0;
  30. virtual ISmartSocket *connect( )=0;
  31. virtual ISmartSocket *connect_timeout(unsigned timeoutms)=0;
  32. virtual ISmartSocket *connectNextAvailableSocket() = 0;
  33. virtual SocketEndpoint& nextEndpoint() = 0;
  34. virtual bool getStatus(SocketEndpoint &ep) = 0;
  35. virtual void setStatus(SocketEndpoint &ep, bool status) = 0;
  36. virtual void stop() = 0;
  37. virtual void resolveHostnames() = 0;
  38. virtual StringBuffer & getUrlStr(StringBuffer &str, bool useHostName) = 0;
  39. };
  40. interface jlib_thrown_decl ISmartSocketException : extends IException
  41. {
  42. };
  43. jlib_decl ISmartSocketFactory *createSmartSocketFactory(const char *_socklist, bool _retry = false, unsigned _retryInterval = 60, unsigned _dnsInterval = (unsigned) -1);
  44. jlib_decl ISmartSocketException *createSmartSocketException(int errorCode, const char *msg);
  45. #endif