I interpret your question in a way that you refer to TCP/IP sockets. With UDP/IP sockets it is different.
Two scenarios:
Scenario 1: 1. bind 2. connect 3. listen
Result: You cannot listen at a connected socket.
>>> import socket >>> s = socket.socket() >>> s.bind(('', 0)) >>> s.send(b'a') Traceback (most recent call last): File "<pyshell#130>", line 1, in <module> s.send(b'a') OSError: [WinError 10057] A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied >>> s.connect(('google.de', 80)) >>> s.listen(1) Traceback (most recent call last): File "<pyshell#132>", line 1, in <module> s.listen(1) OSError: [WinError 10056] A connect request was made on an already connected socket
Scenario 2: 1. bind 2. listen 3. connect
Result: You can not connect or send at a listening socket.
>>> s = socket.socket() >>> s.bind(('', 0)) >>> s.listen(1) >>> s.connect(('google.de', 80)) Traceback (most recent call last): File "<pyshell#136>", line 1, in <module> s.connect(('google.de', 80)) OSError: [WinError 10022] An invalid argument was supplied >>> s.send(b"123") Traceback (most recent call last): File "<pyshell#137>", line 1, in <module> s.send(b"123") OSError: [WinError 10057] A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied