Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

socket, reset and process crash

228 views
Skip to first unread message

ittium

unread,
Sep 11, 2011, 2:33:55 AM9/11/11
to
Group,

I have two small doubts regarding BSD socket APIs on linux

1. Is is possible to send a reset on a running connection or connection
attempt **from the application **. I understand stack can do it.

2. When a program crashes or forcefully killed what happens to it open
connections and it it is server to listening socket.
thanks
Ittium

Volker Birk

unread,
Sep 11, 2011, 4:00:46 AM9/11/11
to
ittium <itt...@gmail.com> wrote:
> I have two small doubts regarding BSD socket APIs on linux
> 1. Is is possible to send a reset on a running connection or connection
> attempt **from the application **. I understand stack can do it.

Maybe shutdown(2) is what you're searching for.

> 2. When a program crashes or forcefully killed what happens to it open
> connections and it it is server to listening socket.

The connections should be closed.

Yours,
VB.
--
Wenn Du für eine Leistung nichts bezahlst,
bist Du nicht der Kunde, sondern die Ware.

ittium

unread,
Sep 11, 2011, 8:08:37 AM9/11/11
to
On 11-09-2011 PM 01:30, Volker Birk wrote:
> ittium<itt...@gmail.com> wrote:
>> I have two small doubts regarding BSD socket APIs on linux
>> 1. Is is possible to send a reset on a running connection or connection
>> attempt **from the application **. I understand stack can do it.
>
> Maybe shutdown(2) is what you're searching for.

Not really, shutdown/close will initiate 4 way connection closing on TCP
socket (or similar procedure on other connection oriented sockets). I
want to abort the connection. Some more research revealed, I can abort
the connection by setting linger interval of 0 on the socket and then
doing close, It seems their is no explicit API.

>
>> 2. When a program crashes or forcefully killed what happens to it open
>> connections and it it is server to listening socket.
>
> The connections should be closed.

Please take in to consideration, that process is either crashed or
killed by sending signal 9.Will the server port and connection be closed
immediately or operating system will do cleanup later on. Whether it is
four way close (considering TCP) or connection abort.

>
> Yours,
> VB.

Barry Margolin

unread,
Sep 11, 2011, 4:01:59 PM9/11/11
to
In article <j4i8c5$djp$1...@dont-email.me>, ittium <itt...@gmail.com>
wrote:

> On 11-09-2011 PM 01:30, Volker Birk wrote:
> > ittium<itt...@gmail.com> wrote:
> >> I have two small doubts regarding BSD socket APIs on linux
> >> 1. Is is possible to send a reset on a running connection or connection
> >> attempt **from the application **. I understand stack can do it.
> >
> > Maybe shutdown(2) is what you're searching for.
>
> Not really, shutdown/close will initiate 4 way connection closing on TCP
> socket (or similar procedure on other connection oriented sockets). I
> want to abort the connection. Some more research revealed, I can abort
> the connection by setting linger interval of 0 on the socket and then
> doing close, It seems their is no explicit API.

If you specify SHUT_WR, it sends a FIN on the connection. If you
specify SHUT_RD, it doesn't send anything. If the other end sends
something after you've done this, I don't think the spec is specific:
either the new data could be ignored, or it can trigger a RST.

I don't think there's anything in the API that sends a RST immediately.

>
> >
> >> 2. When a program crashes or forcefully killed what happens to it open
> >> connections and it it is server to listening socket.
> >
> > The connections should be closed.
>
> Please take in to consideration, that process is either crashed or
> killed by sending signal 9.Will the server port and connection be closed
> immediately or operating system will do cleanup later on. Whether it is
> four way close (considering TCP) or connection abort.

I'm not sure if POSIX specifies it, but I think most implementations do
a normal close immediately.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Alan Curry

unread,
Sep 11, 2011, 5:53:33 PM9/11/11
to
In article <barmar-A703BD....@news.eternal-september.org>,

Barry Margolin <bar...@alum.mit.edu> wrote:
>In article <j4i8c5$djp$1...@dont-email.me>, ittium <itt...@gmail.com>
>wrote:
>
>> On 11-09-2011 PM 01:30, Volker Birk wrote:
>> > ittium<itt...@gmail.com> wrote:
>> >> I have two small doubts regarding BSD socket APIs on linux
>> >> 1. Is is possible to send a reset on a running connection or connection
>> >> attempt **from the application **. I understand stack can do it.
>> >
>> > Maybe shutdown(2) is what you're searching for.
>>
>> Not really, shutdown/close will initiate 4 way connection closing on TCP
>> socket (or similar procedure on other connection oriented sockets). I
>> want to abort the connection. Some more research revealed, I can abort
>> the connection by setting linger interval of 0 on the socket and then
>> doing close, It seems their is no explicit API.
>
>If you specify SHUT_WR, it sends a FIN on the connection. If you
>specify SHUT_RD, it doesn't send anything. If the other end sends
>something after you've done this, I don't think the spec is specific:
>either the new data could be ignored, or it can trigger a RST.
>
>I don't think there's anything in the API that sends a RST immediately.

RST tells the peer that something it sent was not read by the local
application. (The RST sent in response to a SYN on a port where nobody's
listening is a special case of that, in which the local application is
nonexistent.)

Since the kernel knows whether the RST condition applies, there is no need
for userspace to be allowed to request the sending of a RST packet. The
kernel sends them in the correct circumstances already. If you want to send
incorrect packets, that's what raw sockets are for.

>
>>
>> >
>> >> 2. When a program crashes or forcefully killed what happens to it open
>> >> connections and it it is server to listening socket.
>> >
>> > The connections should be closed.
>>
>> Please take in to consideration, that process is either crashed or
>> killed by sending signal 9.Will the server port and connection be closed
>> immediately or operating system will do cleanup later on. Whether it is
>> four way close (considering TCP) or connection abort.
>
>I'm not sure if POSIX specifies it, but I think most implementations do
>a normal close immediately.

If there's unread data in the receive queue when the socket is closed, it
should generate a RST. Otherwise, it shouldn't.

--
Alan Curry

0 new messages