blob: 1ffca456df8ff21e076500ab98a5ebf7fd5d3997 [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);
Pierre Ossman5d055462018-05-03 14:04:38 +020040
Pierre Ossman5d055462018-05-03 14:04:38 +020041 virtual char* getPeerAddress();
Pierre Ossman5d055462018-05-03 14:04:38 +020042 virtual char* getPeerEndpoint();
Pierre Ossman5d055462018-05-03 14:04:38 +020043
Pierre Ossman5d055462018-05-03 14:04:38 +020044 virtual bool cork(bool enable);
Pierre Ossman5d055462018-05-03 14:04:38 +020045 };
46
47 class UnixListener : public SocketListener {
48 public:
49 UnixListener(const char *listenaddr, int mode);
Pierre Ossman5d055462018-05-03 14:04:38 +020050 virtual ~UnixListener();
51
Pierre Ossman5d055462018-05-03 14:04:38 +020052 int getMyPort();
Pierre Ossman559e8b82018-05-04 12:44:31 +020053
54 protected:
55 virtual Socket* createSocket(int fd);
Pierre Ossman5d055462018-05-03 14:04:38 +020056 };
57
58}
59
60#endif // __NETWORK_UNIX_SOCKET_H__