Re: To Block or not to Block
From: Lev Walkin (vlm_at_lionet.info)
Date: 07/16/04
- Next message: Jens.Toerring_at_physik.fu-berlin.de: "Re: To Block or not to Block"
- Previous message: Lev Walkin: "Re: Listening Socket Question"
- In reply to: Robin Cawsey: "To Block or not to Block"
- Next in thread: David Schwartz: "Re: To Block or not to Block"
- Reply: David Schwartz: "Re: To Block or not to Block"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 16 Jul 2004 02:05:07 -0700
Robin Cawsey wrote:
> Hi,
> I've written a client server application using
> non-blocking sockets and most of the time it works fine, apart from
> when a message is send down the socket that causes the the
> non-blocking socket to want to block. This however returns an error
> because it's not able to block.
>
> Therefore is there anyway to get round this problem without setting
> the socket to block and not having to send the message in smaller
> chunks.
You should really, REALLY consider reorganizing the code structure
to allow sending message in smaller chunks and be able to retry transfer
after socket declared that its buffers are full. It will not necesserely
mean that the sender host will paketize the message differently.
Readings:
1. man poll, man select - for socket availability monitoring: to send
or receive only when the socket is ready.
2. man setsockopt, section on SO_SNDBUF: to set a larger buffer
which can help you to have better network paketization.
3. man setsockopt, section on SO_SNDLOWAT: to allow select() or
poll() only return when it is known that the socket buffers
can accomodate a certain (.sndbuf - .sndlowat) number of bytes
without blocking.
-- Lev Walkin vlm@lionet.info
- Next message: Jens.Toerring_at_physik.fu-berlin.de: "Re: To Block or not to Block"
- Previous message: Lev Walkin: "Re: Listening Socket Question"
- In reply to: Robin Cawsey: "To Block or not to Block"
- Next in thread: David Schwartz: "Re: To Block or not to Block"
- Reply: David Schwartz: "Re: To Block or not to Block"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|