Re: Non blocking socket query.
From: Lawrie (stroker_ace_at_hotmail.com)
Date: 04/08/05
- Next message: c_jena_at_ureach.com: "Running same unix script in different shells"
- Previous message: djake_at_excite.it: "Re: Debugging make file"
- In reply to: Fletcher Glenn: "Re: Non blocking socket query."
- Next in thread: Alex Fraser: "Re: Non blocking socket query."
- Reply: Alex Fraser: "Re: Non blocking socket query."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 8 Apr 2005 02:01:26 -0700
> I had a similar problem. The solution was to create a separate
persistent
> send
> data buffer for each socket connection. I would then use select to
> determine
> if any socket was ready to accept send data and then send as much as
I
> could.
> This solution requires that you do your own housekeeping on send
buffers,
> and
> you must periodically check (using select) to see if any more data
can be
> sent.
Okay, let me see If I have got this.
Inside my main loop I am doing two things:
1. Reading messages from input queue and adding them to each sockets
output buffer (Each socket instance is wrapped in a structure with
containing output buffer, status info etc).
2. Call select() with a short timeout. If any sockets are writeable
write as much data as possible to the socket.
Or in pseudo code:
do {
check_input_queue;
if (message arrived) {
add_message_to each_sockets_output_buffer;
}
call select() with small timout.
if (any socket is writeable)
{
write_as_much_data_as_possible_to_socket;
)
} while (!fatal error)
I have one additional question:
I have set my sockets to write only using the shut function because I
want to prevent remote applications sending data to me. Is there any
way using select of detecting a remote disconnect?
Many thanks
Lawrie
- Next message: c_jena_at_ureach.com: "Running same unix script in different shells"
- Previous message: djake_at_excite.it: "Re: Debugging make file"
- In reply to: Fletcher Glenn: "Re: Non blocking socket query."
- Next in thread: Alex Fraser: "Re: Non blocking socket query."
- Reply: Alex Fraser: "Re: Non blocking socket query."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|