Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2001 07:39 AM
тАО08-09-2001 07:39 AM
When a TCP write is done on a socket, does the data get written to the TCP buffer in an atomic manner?
For eg. if 10K is written on the socket using a single write, can the receive call return less than 10K (say 8K in the first call and 2K in the nect call) ?
Kapil
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2001 09:04 AM
тАО08-09-2001 09:04 AM
Re: sockets
When you read from a socket, you may specify the byte count to read.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2001 12:48 PM
тАО08-09-2001 12:48 PM
SolutionTCP is a byte-stream protocol. You feed it a stream of bytes (in whatever size chunks you choose) and a stream of bytes arrives at the other end.
A send() of 10K of data may result in several 1460 byte recv()'s or some other value <= 10K.
Your application has to be prepared to do things to preserve message boundaries. Typically, this is done by pre-pending a "header" with the total message size in it.
I would suggest you write this "header" and the data to the socket at the same time - with say a call to writev() or sendmsg(). Do not do separate writes or you will encounter the nagle algorithm.
the works of W. Richard Stevens would be very good to have handy if you are going to do any "network programming"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2001 12:52 PM
тАО08-09-2001 12:52 PM
Re: sockets
I suggest you look at the sendmsg() and recvmsg() system calls. These will come closest to doing what I think you are trying to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2001 01:05 PM
тАО08-09-2001 01:05 PM
Re: sockets
I'd add to Rick's comments. In order to compose messages (records) from the byte stream arriving on your socket, and achieve some fidelity to what you pass to your application, I generally prepend a header and append a trailer.
The header can include a character count (length inclusive string) which you then use to give a level of assurance that you received what you expected when you have found the trailer.
As framing characters we use 'stx' for the header; and the pair 'fs' & 'cr' for the trailer.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2001 06:41 AM
тАО08-14-2001 06:41 AM
Re: sockets
That piece of information was helpful.
Was there a reason for mentioning 1460 or was it just a random figure you mentioned?
Also what is the Nagle Algorithm and when does it come into picture?
Thanks to all of you for your replies.
Kapil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2001 07:45 AM
тАО08-14-2001 07:45 AM
Re: sockets
When short messages are transmitted with TCP/IP they are packed to avoid or reduce network congestion. The Nagle algorithm delays transmission of short messages to attempt to wait until more messages are available.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2001 11:24 AM
тАО08-23-2001 11:24 AM
Re: sockets
as for the rest - that is what Stevens' books are for !-) i suspect you could find boatloads of opinions on the nagle algorithm with a usenet search at groups.deja.com - some of them - the correct ones of course!-) would even be from me :)