473,385 Members | 1,275 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Winsock recv function

Jay
Hey There,
I have a situation that is occurring that I need help in
understanding. I have a thread that has a recv function in it, and I
have a child thread of that original thread that processes the data.
The parent thread will execute a bunch of recvs normally, but then will
read less data than is there. For example, if I expect a packet of 1056
bytes, only 284 are returned from the recv. When I put a Sleep()
function before the recv call, then it will receive the full 1056 bytes
and continue on it's merry way. What in recv could cause this?

-Jay
(patelj27b at gmail dot com)

Oct 12 '06 #1
1 1671
"Jay" <pa*******@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
I have a situation that is occurring that I need help in
understanding. I have a thread that has a recv function in it, and I
have a child thread of that original thread that processes the data.
The parent thread will execute a bunch of recvs normally, but then will
read less data than is there. For example, if I expect a packet of 1056
bytes, only 284 are returned from the recv. When I put a Sleep()
function before the recv call, then it will receive the full 1056 bytes
and continue on it's merry way. What in recv could cause this?
The connection is stream oriented rather than message oriented. When recv()
completes successfully, the only thing that you can be sure of is that there
is at least one byte data. It is left for the application to call recv() as
many times as is necessary.

For that reason, applications need to define their own way of delimiting
messages. Sometimes that is done by prepending a header in which the length
of application data is specified at a fixed spot in the header. Other
applications use a sentinel byte to indicate logical end of message. And
some senders simply close the connection so that the failure of a subsequent
recv() is taken to mean that all data has been received.

Regards,
Will
Oct 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dom | last post by:
I'm new to c++. Just started learning it 24 hours ago. Am running into a compile problem. Please, no one waste the effort telling me to google it. I've been researching it for quite a while with no...
0
by: fusgerm | last post by:
I was curious to know the size of the internal winsock read-buffer associated with a telnet socket. I wanted to know how long it would take to fill it on my internet connection, and I wanted to set...
1
by: raghupise | last post by:
Hi Friends, In socket programming I want to send double byte charcters. Earlier we used recv() function for single byte charcter. If we use double byte chracter in below recv function, its...
0
by: raghupise | last post by:
Hi Friends, In socket programming I want to connect double byte charcters. Earlier we used recv() function for single byte charcter. If we use double byte chracter in below recv function, its...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.