Forums

Client-server app based on socket (how to make it work here?)

Hello, I'm working on my client-server project and I need to run it somewhere to show my teacher that it works. Can I run my server here? Here is a link to its GitHub page sys_monitor/server.py.

I use socket and server_socket = socket(AF_INET, SOCK_STREAM), and I use only builtin libraries - threading, sqlite3, datetime and re.

And if it's possible, how do I setup server IP and port?

self.address = 'localhost'
self.port = 5000
...
server_socket = socket(AF_INET, SOCK_STREAM)
server_socket.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
server_socket.bind((self.address, self.port))
server_socket.listen()
...
client_socket, addr = server_socket.accept()

If it's impossible, what alternatives do I have? Thank you!

If i just run it as it is (with 'localhost' and 5000) I get this error: OSError: [Errno 98] Address already in use.

can you describe the use case / what exactly you need? are you familiar with the command line / can you use screen/tmux etc?

I need to launch the server on pythonanywhere, and client on some other PCs to be able to record their load (cpu, ram, etc...). I'm not that good at command line, but I can google something and follow instructions.

Unfortunately we don't support socket-based servers -- only websites using the WSGI middleware to connect them to the front-end web server, for example Django, web2py or Flask.