Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import time
- def messageStream():
- while True:
- incommingMessages = c.recv(1024)
- print incommingMessages
- for client in clients:
- c.send(incommingMessages)
- print "Loading..."
- host = '0.0.0.0'
- port = 4998
- print str(host) + ":" + str(port)
- s = socket.socket() #Creates a socket object
- s.bind((host,port)) #Binds the IP to the Port
- s.listen(10) #Listens for incomming TCP Connections
- print "Server Online" #server is now online and listening
- while 1:
- clients = []
- c, addr = s.accept() #if detected, accepts the connection
- print "<" + time.ctime() + ">" + " Connection from: " + str(addr) #print that a client connected
- if addr not in clients: #If that client's IP doesn't exist in the clients list, add it
- clients.append(addr)
- c.send("Connection Successful! Welcome <3")
- try:
- incommingMessage= c.recv(1024)
- print "<" + time.ctime() + ">" + " From " + str(addr) + ": " + str(incommingMessage)
- for client in clients:
- print "send"
- s.send(incommingMessage, client)
- except:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement