Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
172f374a
Commit
172f374a
authored
Sep 02, 2011
by
Sandro Tosi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#12781: Mention SO_REUSEADDR flag near socket examples
parent
d9e17893
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
Doc/library/socket.rst
Doc/library/socket.rst
+19
-0
No files found.
Doc/library/socket.rst
View file @
172f374a
...
...
@@ -1014,6 +1014,25 @@ the interface::
s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
Running an example several times with too small delay between executions, could
lead to this error::
socket.error: [Errno 98] Address already in use
This is because the previous execution has left the socket in a ``TIME_WAIT``
state, and can't be immediately reused.
There is a :mod:`socket` flag to set, in order to prevent this,
:data:`socket.SO_REUSEADDR`::
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((HOST, PORT))
the :data:`SO_REUSEADDR` flag tells the kernel to reuse a local socket in
``TIME_WAIT`` state, without waiting for its natural timeout to expire.
.. seealso::
For an introduction to socket programming (in C), see the following papers:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment