Basics for Socket Programming_Python User Input


•   Socket is the endpoint of a bidirectional communications channel between server and client. Sockets may communicate within a process, between processes on the same machine, or between processes on different machines. For any communication with a remote program, we have to connect through a socket port.  

•    So we will design both server and client model so that each can communicate with them. 


The steps can be considered:



1.  Python socket server program executes at first and wait for any request

2.  Python socket client program will initiate the conversation at first.

3.  Then server program will response accordingly to client requests.


Getting user input from the keyboard 



There are two functions in Python that you can use to read data from the user:
1. raw_input 
2.  input

You can store the results from them into a variable.

Example1:

name=raw_input("what is your name???")

s.send(name)


Example2:

age=input("What is your age???")

s.send(str(age))




No comments:

Post a Comment

Client Server architecture is easy to implement in Python programming language as compared to other languages like C and JAVA. In this blog...