0

我想使用一个网站向客户端应用程序发送一些命令,但在我的主机中我只能访问端口 80 和 443 是否可以使用这些端口进行套接字编程?

我已经在某些端口(例如 8889)上尝试了我的代码,但这些在我的主机上不可用

    def send_to_client(key)://///the function on website that sends data to client
        HOST = '10.42.0.158'  # The server's hostname or IP address
        PORT = 8889       # The port used by the server
        connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        connection.connect((HOST, PORT))
        print("problem with socket")
        # old = termios.tcgetattr(sys.stdin)
        tty.setcbreak(sys.stdin.fileno())
        try:    
            /////if key is ok send it to client app
                connection.sendall(key)
                return key + " sent succesfully"
            else:
                return "not proper input"
                            # key = sys.stdin.read(1)
        finally:
            termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old)    

    def recv_data()://///the function on client app that receive data from website
        global data
        #now keep talking with the client
        while 1:
            #wait to accept a connection - blocking call
            conn, addr = s.accept()
            print ('Connected with ' + addr[0] + ':' + str(addr[1]))
            while True:

                d = conn.recv(1024).strip().decode('utf-8')
                data = d
                break

我想知道是否可以使用端口 80 来执行此套接字编程应用程序

4

0 回答 0