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.
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.
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.
*****************************************************************
Comments
Raja
30-Aug-2020 07:05:05 PM