Skip to content

Commit

Permalink
Socket reuse port
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosalles committed Sep 8, 2016
1 parent deb2fe0 commit 5dd4b81
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions httphandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def sendResponse(self, response_body, mime_type, status):
response_headers_raw = ''.join('%s: %s\r\n' % (k, v) for k, v in response_headers.iteritems())
self.conexao.send('%s %s\r\n' % (response_proto, status))
self.conexao.send(response_headers_raw)
self.conexao.send('\r\n%s\r\n' % response_body)
self.conexao.send('\r\n%s' % response_body)
self.conexao.close()
logger.info('Respondemos para o Cliente [%s] com o status [%s] com a header:\n%s' % (
logger.info('Respondemos para o Cliente [%s] com o status [%s] com a header:\n%s\n' % (
self.cliente, status, response_headers))

def buildHeaders(self, mime_type, response):
Expand Down
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def get_args():
tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
# Aceita qualquer requeste de qualquer endereço, que venha na porta
orig = ('0.0.0.0', PORT)
tcp.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
tcp.bind(orig)
# Começa a ouvir
tcp.listen(1)
Expand Down

0 comments on commit 5dd4b81

Please sign in to comment.