Skip to content

Instantly share code, notes, and snippets.

@andrask
Created December 9, 2015 09:28

Revisions

  1. andrask created this gist Dec 9, 2015.
    16 changes: 16 additions & 0 deletions connect_without_accept.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #! /usr/bin/env python
    '''
    This is a test script for http://serverfault.com/questions/741633/connection-refused-on-rhel-localhost-with-running-server
    '''
    import socket

    port = 12000

    serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    serversocket.bind(('localhost', port))
    serversocket.listen(0)

    for i in range(1, 50):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect(("localhost", port))
    print i