Skip to content

Instantly share code, notes, and snippets.

@lst15
Created April 10, 2018 14:21
Show Gist options
  • Select an option

  • Save lst15/822e6deab253a77d1574acda4872df98 to your computer and use it in GitHub Desktop.

Select an option

Save lst15/822e6deab253a77d1574acda4872df98 to your computer and use it in GitHub Desktop.
servidor.chat.python
import socket
host = '0.0.0.0' #COLOCAR AQUI O IP HOSTEADOR
port = 666 #COLOCAR PORTA DE COMUNICAÇÃO
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.bind((host,port))
socket.listen(2) #QUANTIDADE DE CONEXÕES DENTRO DESTE SERVIDOR
print 'Esperando uma conexao'
while True:
cliente, addr = socket.accept()
while True:
print cliente.recv(1024)
cliente.send(raw_input('Servidor: '))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment