简体   繁体   中英

How to make python server public to other computers in a Linux machine?

I have an ubuntu computer and I want it to act as a server. How do I need to configure the ubuntu computer to be accessible from other computers? Let's say I have this very simple python TCP server:

from socket import socket

with socket() as server:
    server.bind(("", 5555))
    server.listen(5)
    print("[+] Server Listening")
    client, addr = server.accept()
    print(f"client connected from address {addr}")

How can I make this server public to other computers to connect?

Well making a server publicly available is something that we need to know more details about your project. What do you mean about public?? Do you want your server to be publicly available to internet?? Or you just want to use it in your local LAN????

One way you can expose your local service publicly is by using some kind of application like localtunnel or ngrok

Example with ngrok: ngrok http 5555

Example with localtunnel: lt --port 5555

These applications will open a tunnel on a random port locally and forward all the connections it gets on the application generated URL to the port you have specified.

Do not use these for production. Not very reliable approach

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM