How to reset TCP connection on Linux?
Grant Edwards
grant.b.edwards at gmail.com
Mon Dec 3 14:54:47 EST 2018
On 2018-12-03, Jon Ribbens <jon+usenet at unequivocal.eu> wrote:
> On 2018-12-03, Grant Edwards <grant.b.edwards at gmail.com> wrote:
>> How does one reset a TCP connection on Linux? Note that I want to
>> reset the connection, not close it.
>
> Something like the following should work I believe, although I have
> not tested it:
>
> sock.setsockopt(
> socket.SOL_SOCKET,
> socket.SO_LINGER,
> struct.pack('ii', 1, 0)
> )
> sock.close()
Yes!
Setting SO_LINGER with a 0 timeout is the answer. I've been googling
for that (on and off) for the past week, and just could not come up
with the right search terms. Of course adding so_linger to just about
any of my attempts leads immediately to detailed descriptions
including cites to the appropriate section of Stevens and pointers to
where in the kernel it's actually implemented.
Here's a good page:
http://deepix.github.io/2016/10/21/tcprst.html
--
Grant Edwards grant.b.edwards Yow! I had a lease on an
at OEDIPUS COMPLEX back in
gmail.com '81 ...
More information about the Python-list
mailing list