* Re: sending data on a socket followed by a close
2003-08-28 6:01 ` David S. Miller
@ 2003-08-27 19:14 ` Nagendra Singh Tomar
0 siblings, 0 replies; 5+ messages in thread
From: Nagendra Singh Tomar @ 2003-08-27 19:14 UTC (permalink / raw)
To: Lee Chin; +Cc: David S. Miller, hahn, linux-newbie, linux-net
Receiver (in ur discussion) should be sending the RST not the sender.
But ur explaination seems to hint that the sender of data is the one
sending RST.
tomar
On Thu, 28 Aug 2003, David S. Miller wrote:
> On Wed, 27 Aug 2003 19:35:52 -0500
> "Lee Chin" <leechin@mail.com> wrote:
>
> > At the end, after sending all my data, I "close" the socket.
> >
> > However, the client sees a TCP RST packet and only receives partial
> data.
> >
> > What am I doing wrong? I though that the close would actually kill
> the socket after all the data has been sent
>
> You cannot close() the socket until you have emptied all
> the data bytes on the read side of the socket(), if data
> remains on the read side when you close() a TCP RST packet
> is sent.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-net" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 5+ messages in thread
* sending data on a socket followed by a close
@ 2003-08-28 0:35 Lee Chin
2003-08-28 6:01 ` David S. Miller
2003-08-29 5:03 ` Stephen Samuel
0 siblings, 2 replies; 5+ messages in thread
From: Lee Chin @ 2003-08-28 0:35 UTC (permalink / raw)
To: hahn, linux-newbie, linux-net
Hi,
I am trying to send 500K on a asynchronous socket and after I've written all my data, I want to close the socket.
So I send data in a loop, and between calls to "write" I select on the filedescriptor till it is writable again and send more data.
I continue this untill I have no more data to send.
At the end, after sending all my data, I "close" the socket.
However, the client sees a TCP RST packet and only receives partial data.
What am I doing wrong? I though that the close would actually kill the socket after all the data has been sent
Thanks
Lee
--
__________________________________________________________
Sign-up for your own personalized E-mail at Mail.com
http://www.mail.com/?sr=signup
CareerBuilder.com has over 400,000 jobs. Be smarter about your job search
http://corp.mail.com/careers
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sending data on a socket followed by a close
2003-08-28 0:35 sending data on a socket followed by a close Lee Chin
@ 2003-08-28 6:01 ` David S. Miller
2003-08-27 19:14 ` Nagendra Singh Tomar
2003-08-29 5:03 ` Stephen Samuel
1 sibling, 1 reply; 5+ messages in thread
From: David S. Miller @ 2003-08-28 6:01 UTC (permalink / raw)
To: Lee Chin; +Cc: hahn, linux-newbie, linux-net
On Wed, 27 Aug 2003 19:35:52 -0500
"Lee Chin" <leechin@mail.com> wrote:
> At the end, after sending all my data, I "close" the socket.
>
> However, the client sees a TCP RST packet and only receives partial data.
>
> What am I doing wrong? I though that the close would actually kill the socket after all the data has been sent
You cannot close() the socket until you have emptied all
the data bytes on the read side of the socket(), if data
remains on the read side when you close() a TCP RST packet
is sent.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sending data on a socket followed by a close
2003-08-28 0:35 sending data on a socket followed by a close Lee Chin
2003-08-28 6:01 ` David S. Miller
@ 2003-08-29 5:03 ` Stephen Samuel
2003-08-29 5:44 ` Marco Cova
1 sibling, 1 reply; 5+ messages in thread
From: Stephen Samuel @ 2003-08-29 5:03 UTC (permalink / raw)
To: Lee Chin, linux-newbie, linux-net
Rather than using close, try calling shutdown (2)...
(dunno if it will work).
If that doesn't work, then use the socket option SO_LINGER
SO_LINGER When enabled, a close(2) or shutdown(2) will not return
until all queued messages for the socket have been
successfully sent or the linger timeout has been reached.
Otherwise, the call returns immediately and the closing
is done in the background.
man 7 socket
for more info
Lee Chin wrote:
> Hi,
> I am trying to send 500K on a asynchronous socket and after I've written all my data, I want to close the socket.
>
> So I send data in a loop, and between calls to "write" I select on the filedescriptor till it is writable again and send more data.
>
> I continue this untill I have no more data to send.
>
> At the end, after sending all my data, I "close" the socket.
>
> However, the client sees a TCP RST packet and only receives partial data.
>
> What am I doing wrong? I though that the close would actually kill the socket after all the data has been sent
>
> Thanks
> Lee
--
Stephen Samuel +1(604)876-0426 samuel@bcgreen.com
http://www.bcgreen.com/~samuel/
Powerful committed communication. Transformation touching
the jewel within each person and bring it to life.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sending data on a socket followed by a close
2003-08-29 5:03 ` Stephen Samuel
@ 2003-08-29 5:44 ` Marco Cova
0 siblings, 0 replies; 5+ messages in thread
From: Marco Cova @ 2003-08-29 5:44 UTC (permalink / raw)
To: Stephen Samuel; +Cc: Lee Chin, linux-newbie, linux-net
Il giorno Thu, Aug 28, 2003 at 10:03:14PM -0700, pare che Stephen Samuel abbia scritto:
> Rather than using close, try calling shutdown (2)...
> (dunno if it will work).
>
> If that doesn't work, then use the socket option SO_LINGER
>
> SO_LINGER When enabled, a close(2) or shutdown(2) will not return
> until all queued messages for the socket have been
> successfully sent or the linger timeout has been reached.
> Otherwise, the call returns immediately and the closing
> is done in the background.
>
> man 7 socket
> for more info
>
> Lee Chin wrote:
> >Hi,
> >I am trying to send 500K on a asynchronous socket and after I've written
> >all my data, I want to close the socket.
> >
> >So I send data in a loop, and between calls to "write" I select on the
> >filedescriptor till it is writable again and send more data.
> >
> >I continue this untill I have no more data to send.
> >
> >At the end, after sending all my data, I "close" the socket.
> >
> >However, the client sees a TCP RST packet and only receives partial data.
> >
> >What am I doing wrong? I though that the close would actually kill the
> >socket after all the data has been sent
RST on close is what you get if you set the SO_LINGER option for the
socket with l_onoff = 1 and l_linger = 0 (and the socket reference
count has dropped to 0).
You can find a complete description of the different choices you have for
closing a connection in Stevens, "UNIX Network Programming", pag
187-191.
HTH,
Marco
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-08-29 5:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-28 0:35 sending data on a socket followed by a close Lee Chin
2003-08-28 6:01 ` David S. Miller
2003-08-27 19:14 ` Nagendra Singh Tomar
2003-08-29 5:03 ` Stephen Samuel
2003-08-29 5:44 ` Marco Cova
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox