File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1014,6 +1014,25 @@ the interface::
10141014 s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
10151015
10161016
1017+ Running an example several times with too small delay between executions, could
1018+ lead to this error::
1019+
1020+ socket.error: [Errno 98] Address already in use
1021+
1022+ This is because the previous execution has left the socket in a ``TIME_WAIT ``
1023+ state, and can't be immediately reused.
1024+
1025+ There is a :mod: `socket ` flag to set, in order to prevent this,
1026+ :data: `socket.SO_REUSEADDR `::
1027+
1028+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
1029+ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
1030+ s.bind((HOST, PORT))
1031+
1032+ the :data: `SO_REUSEADDR ` flag tells the kernel to reuse a local socket in
1033+ ``TIME_WAIT `` state, without waiting for its natural timeout to expire.
1034+
1035+
10171036.. seealso ::
10181037
10191038 For an introduction to socket programming (in C), see the following papers:
You can’t perform that action at this time.
0 commit comments