Re: How can I send many messages from a server to client in socket
From: Bob Hauck (postmaster_at_localhost.localdomain)
Date: 05/30/05
- Next message: Rick: "Re: Why the Linux Desktop Just Won't Work! and why Linux depresses me."
- Previous message: Andrew Schulman: "Re: OT: tools to automate info access from web.."
- In reply to: skprasat_at_gmail.com: "How can I send many messages from a server to client in socket"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 30 May 2005 08:30:17 -0400
On 30 May 2005 04:08:39 -0700, skprasat@gmail.com <skprasat@gmail.com>
wrote:
> what i need is to send these three char array in a single send
> function...
Maybe you could try writev().
But, because your question makes me think you are about to make a common
mistake, let me point out that sending the three arrays together will
not guarantee that all three will be returned together by a read() on
the other end. TCP does not guarantee that and if you assume it does
thne you _will_ get bitten sooner or later.
Instead, you should come up with some scheme for finding the start and
end of each message. If they are always strings, a null byte or NL will
work fine. Look for that token by calling read() in a loop rather than
assuming that the read() will return your whole string in one call.
-- -| Bob Hauck -| A proud member of the reality-based community. -| http://www.haucks.org/
- Next message: Rick: "Re: Why the Linux Desktop Just Won't Work! and why Linux depresses me."
- Previous message: Andrew Schulman: "Re: OT: tools to automate info access from web.."
- In reply to: skprasat_at_gmail.com: "How can I send many messages from a server to client in socket"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|