Created
December 1, 2014 21:18
-
-
Save gbrennon/79fad301ef3bc8d701ea to your computer and use it in GitHub Desktop.
SERVERAXIS
This file contains 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 | |
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