Created
April 10, 2018 14:21
-
-
Save lst15/822e6deab253a77d1574acda4872df98 to your computer and use it in GitHub Desktop.
servidor.chat.python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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