Python Server Program














































Python Server Program



Hello,This is Rohit Kumar.In this Article I will talk about socket programming in Python.

Python provides two levels of access to network services. At a low level, you can access the basic socket support in the underlying operating system, which allows you to implement clients and servers for both connection-oriented and connectionless protocols.

Python also has libraries that provide higher-level access to specific application-level network protocols, such as FTP, HTTP, and so on.


What is Sockets?

Sockets are the endpoints of a bidirectional communications channel. Sockets may communicate within a process, between processes on the same machine, or between processes on different continents.

Sockets may be implemented over a number of different channel types: Unix domain sockets, TCP, UDP, and so on. The socket library provides specific classes for handling the common transports as well as a generic interface for handling the rest.


The socket Module

To create a socket, you must use the socket.socket() function available in socket module, which has the general syntax %u2212

s = socket.socket (socket_family, socket_type, protocol=0)


Here is the image of server side program: 



Output: When we run above code we will find this output.


Socket Created

waiting for connections


Now we run the client side code:


Output: 

Please enter your nameRohit

Welcome to Cppsecrets


If we  run the client side code then we get the output at server side that is given below:

Socket Created

waiting for connections

Connected with ('127.0.0.1',64880) Rohit


Note:

Here you should have to note one thing that at the client side you should have to mention the IP address of the Server.


*****************************************************************

                                                        


More Articles of Rohit Kumar:

Name Views Likes
Python Copy ShallowCopy 323 4
Python PyGreSQL Classic PyGreSQL Interface Advanced Features 409 3
Python Nested Functions 398 3
Python PyGreSQL Classic PyGreSQL Interface DB Wrapper Class 475 3
Python Event Loop 391 4
Python PyGreSQL DB-API PyGreSQL Interface Functions 441 3
Python Shlex get_token() Method 681 4
Python Class Method Use 420 4
Python PyGreSQL Classic PyGreSQL Interface System Catalogs Examples 436 3
Python Multiple Vs Multi-level Inheritence 582 4
Python Shlex error_leader() Method 401 4
Python PyGreSQL Classic PyGreSQL Interface LargeObject 396 3
Python Bisect Insertion Functions 267 4
Python Multiple Inheritence 370 3
Python shlex class 499 4
Python Class Method 404 4
Python Shlex Quoted String 569 3
Python Shlex Methods 461 4
Python PyGreSQL Introduction 637 4
Python PasswordGenerator Project 768 4
Python Shlex Difference between Non-Posix and Posix Parsing 481 3
Python Shlex Functions 870 4
Python Shlex Split Example 520 3
Python PyGreSQL DB-API PyGreSQL Interface Cursor Object 447 3
Python Shlex Error-Handling 479 4
Python Copy deepcopy() 343 4
Python Shlex shlex.split() Vs re.split() 742 3
Python Server Program 748 4
Python Thumb Rule 636 4
Python Class Method Vs Static Method 535 4
Python PyGreSQL Classic PyGreSQL Interface Connection Object 476 4
Python PyGreSQL DB-API 2.0 Interface 465 4
Python PyGreSQL DB-API PyGreSQL Interface Connection Object 400 3
Python Bisect Functions 325 3
Python Loop Types 361 4
Python Bisect Introduction 472 4
Python Copy Introduction 310 4
Python PyGreSQL Classic PyGreSQL Interface Functions 457 3
Python PyGreSQL Classic PyGreSQL Interface SQL Functions Examples 415 3
Python Shlex Introduction 600 4
Python PyGreSQL Classic PyGreSQL Interface Basic Example 644 3
Python Shlex read_token() Method 505 3
Python Copy Shallowcopy Vs Deepcopy 295 4

Comments

  • Raja
    30-Aug-2020 07:05:05 PM
    Very Easy Expaination.Anyone can understand easily...