Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2004

Tip: Looking for answers? Try searching our database.

Could not receive more than 2KB at RECV(..) function.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BilMuh - 11 Jun 2004 12:03 GMT
Hello Developpers,
I am developping a TCP/IP Client application using Visual C++ .NET Standard on Windows 2000 Pro.

I noticed that I could not receive more than 2KB once at a time. The server application sends me intensive data. Before this, I receive a feedback command that informs about what kind of prepations I should do next statements. This feedback command is sometimes more than 2KB (2048 Bytes). If the feedback command is less or equal to 2KB, there is not any problem to receive all of it with one recv(...) functions. In the case of being greater, I should use more than one recv(...) .

In order to solve this, I changed my technique. First, I receive 2 Bytes that says me the size of the feedback command. Than, I run my recv(..) function in a while(...) loop till the expected number of Bytes are received. Than I pass to other operations.

Could you tell me how to resize the recv(..) buffer size!!! I learned that TCPWindowSize is for this purpose. But I could not find any sample.

My initial recv(...) function was as follow:
     ...
     #define Max_Buffer_Size 30000
     ...
     char* recvBuf = new char[Max_Buffer_Size];
     int retRecvVal = recv( ClientSocket , recvBuf , Max_Buffer_Size , 0);
     ...

I would like to thank you in advance for your sincere guidance
William DePalo [MVP VC++] - 11 Jun 2004 14:48 GMT
> I am developping a TCP/IP Client application using Visual
> C++ .NET Standard on Windows 2000 Pro.
>
> I noticed that I could not receive more than 2KB once at a time.

Sockets are most often used in a "stream" oriented, rather than "message" or
"datagram" oriented way. You _must_ be prepared for whatever the network
gives you and if necessary handling the bocking of buffers yourself.

If you switch from TCP to UDP (i.e. from SOCK_STREAM to SOCK_DGRAM) you will
get the message orientation you want. Of course then you give up
"connected-ness" and the reliability of TCP.

Regards,
Will

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.