Benutzer-Werkzeuge

Webseiten-Werkzeuge


python

Python

Unix Domain Sockets

import socket
server_address = /tmp/test.sock

# Sicherstellen daß der Socket nicht existiert
try:
    os.unlink(server_address)
except OSError:
    if os.path.exists(server_address):
        raise

sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.bind(server_address)

sock.listen(1)
while True:
    connection, client_address = sock.accept()
    try:
        while True:
            data = connection.recv(16)
            if data:
                pass
            else:
                break
    finally:
	connection.close()
python.txt · Zuletzt geändert: 06.08.2017 08:35 von thooge

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki