Recent Posts

A journey to enter socket module in python 3x (Part 2)

If you missed part 1 then this article useless for you. So first kindly go part 1
and read that.

Now its time for create a where the client send you a message.

import socket
host = ''
port = 5000
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)

msg = input ('Durdin : ')
while msg!='q'
    msg = msg.encode('utf-8')
    data = sock.recv(1024).decode('utf-8')
    print('Devils says : ',data)
    msg = input('Durdin : ')


Now its time for run those python code ^_^ .

How to run code ? I think you are kidding -_- !
But anyway i say that, if you are a linux user then if your file in Desktop
then you can run it by

python3.4 /root/Desktop/
 If you are a root user. python3.4 this keyword is depend on your system. You can alias it from basr.rc by your terminal and make it as you want.
However if you can't notice your python version then just type on python shell and

import sys

and you can know it.

Now here is the main point 

First run

Then run from other terminal

Now you can notice a message appear in

Now you can chat :) 


Any confusion ?
I have also confusion :(

Post a Comment