How to I force a Data to be send out at once in socket send

  • Follow


Hi,Every One,

 sorry to disturbing. I have truble in my application which should found
network failure as soon as possible. I know,normally tcp send will buffered
data in system send buffer and send out later. and ,the ack won't send back
immedealy for some function to improve tcp performace such as Neagle .How
can i force the send fuction to send the data to the network without
buffering in local buffer?

  What i want to do is when i send out a frame of data via socket,i can get
response like n equal to the length of the frame when remote peer received
the frame of the data ,or -1 when timeout without responce.


0
Reply postbeerliu 12/26/2003 1:07:24 AM

"postbeerliu" <postbeerliu@163.com> wrote in message 
news:bsg3ic$104m$1@mail.cn99.com...
> Hi,Every One,
>
> sorry to disturbing. I have truble in my application which should found
> network failure as soon as possible. I know,normally tcp send will 
> buffered
> data in system send buffer and send out later. and ,the ack won't send 
> back
> immedealy for some function to improve tcp performace such as Neagle .How
> can i force the send fuction to send the data to the network without
> buffering in local buffer?


    You need to tell us what you're trying to do, not how you're trying to 
do it.


>  What i want to do is when i send out a frame of data via socket,i can get
> response like n equal to the length of the frame when remote peer received
> the frame of the data ,or -1 when timeout without responce.


    Then code that. Write exactly what you want and layer it on top of TCP.

    DS


0
Reply David 12/26/2003 5:47:35 AM


In article <bsg3ic$104m$1@mail.cn99.com>,
 "postbeerliu" <postbeerliu@163.com> wrote:

> Hi,Every One,
> 
>  sorry to disturbing. I have truble in my application which should found
> network failure as soon as possible. I know,normally tcp send will buffered
> data in system send buffer and send out later. and ,the ack won't send back
> immedealy for some function to improve tcp performace such as Neagle .How
> can i force the send fuction to send the data to the network without
> buffering in local buffer?
> 
>   What i want to do is when i send out a frame of data via socket,i can get
> response like n equal to the length of the frame when remote peer received
> the frame of the data ,or -1 when timeout without responce.

You can use the TCP_NODELAY socket option to disable Nagle and send data 
immediately.  However, there's no way to make it wait for the ack before 
returning.

Why do you think you need this?  Why do you care when the remote TCP has 
received the data.  What you probably care about is when the remote 
*application* has read the data.  So you should implement an 
acknowledgement mechanism in your protocol.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
0
Reply Barry 12/26/2003 5:59:22 AM

postbeerliu wrote:
> 
> Hi,Every One,
> 
>  sorry to disturbing. I have truble in my application which should found
> network failure as soon as possible. I know,normally tcp send will buffered
> data in system send buffer and send out later. and ,the ack won't send back
> immedealy for some function to improve tcp performace such as Neagle .How
> can i force the send fuction to send the data to the network without
> buffering in local buffer?
> 
>   What i want to do is when i send out a frame of data via socket,i can get
> response like n equal to the length of the frame when remote peer received
> the frame of the data ,or -1 when timeout without responce.

Hi, I have the same/similar question: sometimes data should be flushed
to the remote side (eg: user pressed key ENTER), but I do not see any function
to force this.. (disabling Nagle-algorithm is <i>not exactly</i> the same thing)
0
Reply Lorinczy 12/27/2003 4:47:10 PM

In article <3FEDB78E.7C4FC4F8@axelero.hu>,
 Lorinczy Zsigmond / Domonyik Mariann <lzsiga@axelero.hu> wrote:

> postbeerliu wrote:
> > 
> > Hi,Every One,
> > 
> >  sorry to disturbing. I have truble in my application which should found
> > network failure as soon as possible. I know,normally tcp send will buffered
> > data in system send buffer and send out later. and ,the ack won't send back
> > immedealy for some function to improve tcp performace such as Neagle .How
> > can i force the send fuction to send the data to the network without
> > buffering in local buffer?
> > 
> >   What i want to do is when i send out a frame of data via socket,i can get
> > response like n equal to the length of the frame when remote peer received
> > the frame of the data ,or -1 when timeout without responce.
> 
> Hi, I have the same/similar question: sometimes data should be flushed
> to the remote side (eg: user pressed key ENTER), but I do not see any 
> function
> to force this.. (disabling Nagle-algorithm is <i>not exactly</i> the same 
> thing)

TCP normally sends the data quickly -- the delay you're trying to get 
rid of is on the order of a few milliseconds, not something the user 
would notice.

So I think you're trying to solve a non-problem.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
0
Reply Barry 12/27/2003 10:18:38 PM

Why I want to get rid of this delay is because of when I pull out of the
cable, the send() still don't return -1 to tell me the network is failure .
Maybe it will return -1 later when the system's send buffer is full.
"Barry Margolin" <barmar@alum.mit.edu> д����Ϣ����
:barmar-CEE186.17183527122003@netnews.attbi.com...
> In article <3FEDB78E.7C4FC4F8@axelero.hu>,
>  Lorinczy Zsigmond / Domonyik Mariann <lzsiga@axelero.hu> wrote:
>
> > postbeerliu wrote:
> > >
> > > Hi,Every One,
> > >
> > >  sorry to disturbing. I have truble in my application which should
found
> > > network failure as soon as possible. I know,normally tcp send will
buffered
> > > data in system send buffer and send out later. and ,the ack won't send
back
> > > immedealy for some function to improve tcp performace such as Neagle
..How
> > > can i force the send fuction to send the data to the network without
> > > buffering in local buffer?
> > >
> > >   What i want to do is when i send out a frame of data via socket,i
can get
> > > response like n equal to the length of the frame when remote peer
received
> > > the frame of the data ,or -1 when timeout without responce.
> >
> > Hi, I have the same/similar question: sometimes data should be flushed
> > to the remote side (eg: user pressed key ENTER), but I do not see any
> > function
> > to force this.. (disabling Nagle-algorithm is <i>not exactly</i> the
same
> > thing)
>
> TCP normally sends the data quickly -- the delay you're trying to get
> rid of is on the order of a few milliseconds, not something the user
> would notice.
>
> So I think you're trying to solve a non-problem.
>
> --
> Barry Margolin, barmar@alum.mit.edu
> Arlington, MA


0
Reply postbeerliu 12/28/2003 5:04:37 AM

"postbeerliu" <postbeerliu@163.com> wrote in message 
news:bsloac$jpm$1@mail.cn99.com...


> Why I want to get rid of this delay is because of when I pull out of the
> cable, the send() still don't return -1 to tell me the network is failure 
> .
> Maybe it will return -1 later when the system's send buffer is full.


    Even if 'send' didn't return until the data was sent, that wouldn't mean 
it was received anyway. TCP does guarantee that if you are sending data, you 
will eventually detect a broken network connection. Usually it takes 2 or 3 
minutes. This is what you want -- after all, it would be horrible if TCP 
connections broke every time network connectivity was lost for a few 
seconds.

    DS




0
Reply David 12/28/2003 11:47:58 PM

6 Replies
202 Views

(page loaded in 0.074 seconds)

Similiar Articles:













7/29/2012 7:19:57 PM


Reply: