Skip to content

Instantly share code, notes, and snippets.

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

  • Save lst15/3eb40180acefb1f94b2c270b92e74fdb to your computer and use it in GitHub Desktop.

Select an option

Save lst15/3eb40180acefb1f94b2c270b92e74fdb to your computer and use it in GitHub Desktop.
cliente.chat.python
import socket
serverhost = '127.0.0.1' #IP DO SERVIDOR
serverport = 666 #PORTA DE COMUNICAÇÃO DO SERVIDOR
nameuser = socket.gethostname()
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.connect((serverhost,serverport))
while True:
socket.send(nameuser + ': ' + raw_input('Voce: '))
print 'Servidor: ' + socket.recv(1024)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment