summaryrefslogtreecommitdiff
path: root/systemd/daemon.py
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-03-11 14:26:27 -0500
committerGitHub <noreply@github.com>2017-03-11 14:26:27 -0500
commit753a4ca5ffbea9e7b937dbe5c567353f9ca21f85 (patch)
tree7881ff7c011727acc5c9da7078c70b0aaa440455 /systemd/daemon.py
parentdce0a855c3281e7051b1cbe0f73386d1c90ef320 (diff)
parentbc691d8e293a593fbd14ad1d592d06f4f490ed29 (diff)
downloadpython-systemd-753a4ca5ffbea9e7b937dbe5c567353f9ca21f85.tar.gz
Merge pull request #31 from keszybz/is_socket_sockaddr
daemon: add basic support for sd_is_socket_sockaddr
Diffstat (limited to 'systemd/daemon.py')
-rw-r--r--systemd/daemon.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/systemd/daemon.py b/systemd/daemon.py
index 82011ca..5d398f2 100644
--- a/systemd/daemon.py
+++ b/systemd/daemon.py
@@ -5,6 +5,7 @@ from ._daemon import (__version__,
_is_fifo,
_is_socket,
_is_socket_inet,
+ _is_socket_sockaddr,
_is_socket_unix,
_is_mq,
LISTEN_FDS_START)
@@ -28,6 +29,20 @@ def is_socket_inet(fileobj, family=_AF_UNSPEC, type=0, listening=-1, port=0):
fd = _convert_fileobj(fileobj)
return _is_socket_inet(fd, family, type, listening, port)
+def is_socket_sockaddr(fileobj, address, type=0, flowinfo=0, listening=-1):
+ """Check socket type, address and/or port, flowinfo, listening state.
+
+ Wraps sd_is_socket_inet_sockaddr(3).
+
+ `address` is a systemd-style numerical IPv4 or IPv6 address as used in
+ ListenStream=. A port may be included after a colon (":").
+ See systemd.socket(5) for details.
+
+ Constants for `family` are defined in the socket module.
+ """
+ fd = _convert_fileobj(fileobj)
+ return _is_socket_sockaddr(fd, address, type, flowinfo, listening)
+
def is_socket_unix(fileobj, type=0, listening=-1, path=None):
fd = _convert_fileobj(fileobj)
return _is_socket_unix(fd, type, listening, path)