chatserver
chatserver.py — text/python-source, 1 KB
Dateiinhalt
# -*- coding: utf-8 -*- import socket PORT = 8500 EPORT = 8501 service= socket.socket(socket.AF_INET,socket.SOCK_DGRAM) service.bind(("", PORT)) clients=[] print "Starte Server auf Port", PORT while True: data, client = service.recvfrom(100) if client not in clients: clients.append(client) service.sendto("Es sind außer Dir %s Leute im Chat"%(len(clients)-1),client) print "Verbindung von", client, "schreibt:", data for recievers in clients: if recievers != client: service.sendto(data, recievers)