blob: 48c5b63f48af8f7cfe94186619c6d689f0da94c2 [file] [log] [blame]
Pierre Ossman5d055462018-05-03 14:04:38 +02001/* 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
20// -=- UnixSocket.h - base-class for UNIX stream sockets.
21// This header also defines the UnixListener class, used
22// to listen for incoming socket connections over UNIX
23//
24// NB: Any file descriptors created by the UnixSocket or
25// UnixListener classes are close-on-exec if the OS supports
26// it. UnixSockets initialised with a caller-supplied fd
27// are NOT set to close-on-exec.
28
29#ifndef __NETWORK_UNIX_SOCKET_H__
30#define __NETWORK_UNIX_SOCKET_H__
31
32#include <network/Socket.h>
33
34namespace network {
35
36 class UnixSocket : public Socket {
37 public:
Pierre Ossmand7bbbbf2018-05-21 12:06:47 +020038 UnixSocket(int sock);
Pierre Ossman5d055462018-05-03 14:04:38 +020039 UnixSocket(const char *name);
40 virtual ~UnixSocket();
41
Pierre Ossman5d055462018-05-03 14:04:38 +020042 virtual char* getPeerAddress();
Pierre Ossman5d055462018-05-03 14:04:38 +020043 virtual char* getPeerEndpoint();
Pierre Ossman5d055462018-05-03 14:04:38 +020044
45 virtual void shutdown();
46 virtual bool cork(bool enable);
Pierre Ossman5d055462018-05-03 14:04:38 +020047 };
48
49 class UnixListener : public SocketListener {
50 public:
51 UnixListener(const char *listenaddr, int mode);
Pierre Ossman5d055462018-05-03 14:04:38 +020052 virtual ~UnixListener();
53
54 virtual void shutdown();
55 virtual Socket* accept();
56
57 int getMyPort();
58 };
59
60}
61
62#endif // __NETWORK_UNIX_SOCKET_H__