Amazing technological breakthrough possible @S-Logix

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • +91- 81240 01111

Social List

How to create a simple server using socket module in python?


To create a simple server using socket programming in python3.


   Import socket library.

   Create socket object s.

   Define the port number(5 digits).

   Bind the port and socket object using s.bind().

  Check socket has been created or not.

   Server listening if any connection from client using s.listen().

   If connection available accept the client using s.accept().

   Then stop the server.

Sample Code

#import socket module
import socket

#create socket object
s = socket.socket()
print(“Socket created successfully”)
port = 54546
#Bind the port
s.bind((”, port))

#check the socket binded to the port
print(“socket binded to “,(port))
print(“server listening”)
while True:

#accept the connection
c, addr=(s.accept())

#send status message to the client

#Terminate the connection

create a simple server using socket module in python