Search code examples
pythonsocketsserverserversocketpython-sockets

How to get Socket server address and port of an instant messenger?


I am using an instant messenger bot. Recently Instant messenger(palringo) has changed the connection setting, and I have no idea how to get new socket server address and port that can connect bot to the Instant Messenger.

Code:

 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        server_address = ('80.69.129.4',12345);
        print('Attempting to connect to the server')
        try:
            sock.connect(server_address)

Solution

  • If you want to change the Host or Addr maybe you can use some command to input them

    #!/usr/bin/python
    
    HOST=raw_input('please input HOST: ')
    PORT=raw_input('please input PORT: ')
    

    then you change the HOST and PORT

    s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    s.connect((HOST,PORT))