Method Name:
accept
Method Signature:
accept()
Parameters:
None
Return Value:
A tuple containing an SSLSocket instance and the IP address of the client. The SSLSocket instance can be used to communicate with the client using TLS.
Overview:
- The method accept(), accepts a connection request from a client.
- The method accept() returns a tuple of SSLSocket and the IP address of the client.
- The first element of the tuple, which is an instance of SSLSocket that can be used for communicating with the client in a secure manner as per TLS protocol.
- The client program used in the Introduction to SSLSocket, can be used for communicating with the server below.
Example:
# Example Python program that accepts new TLS connections # Create an SSL context # Load CA certificate with which the server will # Load server certificate # Work-around for self-signed certificates as Python3.13 is strict # Create a connection oriented server socket # Wrap the socket to get an SSLSocket and bind it to an IP address and port print("Listening and accepting connections") |
Output-Server:
Listening and accepting connections |
Output-Client:
X.509 certificate of the server DemoServer: |