#5, First Floor, 4th Street , Dr. Subbarayan Nagar, Kodambakkam, Chennai-600 024 pro@slogix.in

Office Address

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

Social List

How to create simple server-client program using socket programming in python?


To know how to connect fb using python socket programming using python3.


Import socket library.

Create socket object.

Use socket module methods bind()
,listen(),accept() and connect().

First start the server using
terminal(python3 server.py).

Then start the client by $
telnet local host port number.

Connect client with server.

Sapmle Code

Source code(server):

#import socket module
import socket

#create socket object
s = socket.socket()
print(“Socket created successfully”)
port = 12348

#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
c.send(b”Thanks for connecting”)

#Terminate the connection

Source code(client):

#import socket library
import socket

#create socket object
s = socket.socket()

#declare a port
port = 12348

#make connection
s.connect((‘’, port))
print (s.recv(10))

#close the connection