Socket Server

Anudha Mittal
1 min readAug 8, 2024

--

https://docs.python.org/3/library/socketserver.html#socketserver.TCPServer

Web servers can forward requests to other servers.

For this to happen, another server has to be listening.

If you set up a server to listen on port 5000, check it’s actually listening by using

netstat -tuln

in the result, should see a line like:

tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN

if your list is too long, pipe the results of netstat to a grab function since you already know which port want to check for

netstat -tuln | grep 5000

Notes on stopping and re-starting the python based custom server listening on port 5000

  1. modified the server.py file
  2. ctrl+C on the tmux terminal running the server
  3. site address served by server.py no longer accessible from www
  4. tried to start the modified server.py with a new python process

OSError: [Errno 98] Address already in use

5. re-run #4 after some seconds → successful

Serving on port 5000

6. site address serving file again

This is distinct from the websocket , which is a communication method that uses http to start with and then moves on to a different protocol for interaction betw. client and server.

Web Socket Protocol: https://datatracker.ietf.org/doc/html/rfc6455

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response