You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UnixSocket.h 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright (c) 2012 University of Oslo. All Rights Reserved.
  3. *
  4. * This is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This software is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this software; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  17. * USA.
  18. */
  19. // -=- UnixSocket.h - base-class for UNIX stream sockets.
  20. // This header also defines the UnixListener class, used
  21. // to listen for incoming socket connections over UNIX
  22. //
  23. // NB: Any file descriptors created by the UnixSocket or
  24. // UnixListener classes are close-on-exec if the OS supports
  25. // it. UnixSockets initialised with a caller-supplied fd
  26. // are NOT set to close-on-exec.
  27. #ifndef __NETWORK_UNIX_SOCKET_H__
  28. #define __NETWORK_UNIX_SOCKET_H__
  29. #include <network/Socket.h>
  30. namespace network {
  31. class UnixSocket : public Socket {
  32. public:
  33. UnixSocket(int sock);
  34. UnixSocket(const char *name);
  35. virtual char* getPeerAddress();
  36. virtual char* getPeerEndpoint();
  37. virtual bool cork(bool enable);
  38. };
  39. class UnixListener : public SocketListener {
  40. public:
  41. UnixListener(const char *listenaddr, int mode);
  42. virtual ~UnixListener();
  43. int getMyPort();
  44. protected:
  45. virtual Socket* createSocket(int fd);
  46. };
  47. }
  48. #endif // __NETWORK_UNIX_SOCKET_H__