CommunicationSocket.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or modify it under
  5. * the terms of the GNU Lesser General Public License as published by the Free
  6. * Software Foundation; either version 2.1 of the License, or (at your option)
  7. * any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  12. * details.
  13. */
  14. #ifndef COMMUNICATIONSOCKET_H
  15. #define COMMUNICATIONSOCKET_H
  16. #pragma once
  17. #pragma warning (disable : 4251)
  18. #include <string>
  19. #include <vector>
  20. #include <WinSock2.h>
  21. class __declspec(dllexport) CommunicationSocket
  22. {
  23. public:
  24. static std::wstring DefaultPipePath();
  25. CommunicationSocket();
  26. ~CommunicationSocket();
  27. bool Connect(const std::wstring& pipename);
  28. bool Close();
  29. bool SendMsg(const wchar_t*) const;
  30. bool ReadLine(std::wstring*);
  31. HANDLE Event() { return _pipe; }
  32. private:
  33. HANDLE _pipe;
  34. std::vector<char> _buffer;
  35. bool _connected = false;
  36. };
  37. #endif