Skip to content

Instantly share code, notes, and snippets.

@gbrennon
Created December 1, 2014 21:18
Show Gist options
  • Save gbrennon/79fad301ef3bc8d701ea to your computer and use it in GitHub Desktop.
Save gbrennon/79fad301ef3bc8d701ea to your computer and use it in GitHub Desktop.
SERVERAXIS
import socket
import thread
import os
def server(clientsock, cliente):
while True:
received = con.recv(1024)
if received:
print received
f.write(received)
if __name__=='__main__':
HOST = ''
PORT = 2000
tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
orig = (HOST, PORT)
tcp.bind(orig)
tcp.listen(1)
f = open("var.log", "a")
print f
#ENDTAREFAS INICIAIS
############################################################
while True:
print "...aguardando conexao... escutando a porta ", PORT
con, cliente = tcp.accept() #con -> send/receive cliente-> end do cliente
print "...conectado com", cliente
thread.start_new_thread(server, (con, cliente))
#print >>f,'Conectado por', cliente telecomlab
# while True:
#received = con.recv(1024)
#print received
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment