Re: Network programming
From: Steve Horsley (shoot_at_the.moon)
Date: 01/16/04
- Next message: SR: "ANN: eValid FT-150 Top Page Download Time Survey"
- Previous message: Andrew Thompson: "Re: Java/Linux Always on Top"
- In reply to: SS: "Re: Network programming"
- Next in thread: SS: "Re: Network programming"
- Reply: SS: "Re: Network programming"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 16 Jan 2004 20:11:12 +0000
SS wrote:
>
>
> Ok, so this leads me to another problem then.
> Basically I need write() to be non-blocking. You can make read()
> non-blocking using setSoTimeout(), but it doesn't seem to affect
> write().
>
> For example, suppose I am streaming data from a server to a client,
> and the client for some reason stops reading, but leaves the socket
> open.
> The server eventually fills the write buffers, then gets stuck in
> write().
> I would want to be able to throw away any data that could not be
> written and timeout the server if write failure occurs for some period
> of time.
> However, as long as the client is alive, this is impossible because
> control of the server is never passed back from write().
>
> Anyone have any ideas on this?
>
> Thanks a lot.
Implement your own FIFO with a size limit that throws and Exception or
just discards the excess (your choice). The FIFO needs to be
synchronized and needs to block read() calls when empty.
Start a thread that loops reading the FIFO and writing the socket. It
will spend most of its time blocked in either read() or write().
Now just write to the FIFO rather than direct to the socket.
Steve
- Next message: SR: "ANN: eValid FT-150 Top Page Download Time Survey"
- Previous message: Andrew Thompson: "Re: Java/Linux Always on Top"
- In reply to: SS: "Re: Network programming"
- Next in thread: SS: "Re: Network programming"
- Reply: SS: "Re: Network programming"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|