Python string server address already in usePython for Security Professionals Course

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATION
Already a Member Login Here

Home Forums Courses Python for Security Professionals Course Python string server address already in use

This topic contains 0 replies, has 1 voice, and was last updated by  jefquery 1 year, 2 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #152823

    jefquery
    Participant

    If you have been getting the error:
    socket.error: [Errno 48] Address already in use

    This is a bug. Move the socket creation and binding out of the loop in the StringServer.

    Like this:

    import socket
    
    def main():
        HOST  = ''
        PORT  = 50001    
        s = socket.socket(socket.AF_INET , socket.SOCK_STREAM)
        s.bind((HOST , PORT))
        message_list = ['alpha' , 'bravo' , 'charlie' , 'delta']
        
        for i in message_list:
            s.listen(1)
            conn, addr = s.accept()
            conn.send(i)
            conn.close()
            
    main()

    Hope that helps

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Support Cybrary

Donate Here to Get This Month's Donor Badge

 

We recommend always using caution when following any link

Are you sure you want to continue?

Continue
Cancel