× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: RE: Socket related question...
  • From: "Rich Duzenbury" <rduz@xxxxxxxxxxxxxxxxxxx>
  • Date: Fri, 24 Mar 2000 20:16:26 -0600
  • Importance: Normal

This is indeed the correct behavior.

As much information as is currently available, up to the size of the supplied 
buffer is returned by recv().  If no data is available to be received, the 
recv() function will (generally) wait for data to arrive.  You may have to call 
recv() multiple times to receive a predetermined amount of data.

Here are a few fairly easy ways to implement:
1) You and the client agree ahead of time that the message is of fixed size, so 
your program reads in a loop until it has received the correct number of bytes
2) The first part of the message from the client tells you how many bytes the 
message will be, and your program reads until it has received that many bytes
3) The client appends a delimiter to the message, and your program reads until 
it locates the delimiter.  You have to be a bit careful here to be sure the 
delimiter cannot itself be part of the message.

For variable length messages that are text fields only, I usually use #3 and 
append a carriage return (x'0D') to the message.

And of course, as you already know, the routines do not themselves convert 
between ASCII and EBCDIC.

Send() operates in essentially the same manner.  You should also send in a loop 
checking the status of send until the number of bytes sent is equal to the size 
of your message.  You never know when TCP will decide to send only a portion of 
your buffer.

Also, I normally use send() and recv().  I'm pretty sure read() and write() 
work in the same manner, although someone here will correct me on this if I'm 
incorrect. 

Regards,
Rich

-----Original Message-----
From: owner-rpg400-l@midrange.com [mailto:owner-rpg400-l@midrange.com]On
Behalf Of Sanjiv Hati
Sent: Friday, March 24, 2000 6:07 PM
To: RPG400-L@midrange.com
Subject: Re: Socket related question...


I convert each bytes of the replied string into EBCDIC
and when I view the converted buffer it appears to me
as incomplete (because, in Win NT, I can view the
complete string using another client socket program).
But the read() returns an integer value, which is in
fact number of bytes received i.e. 536 (whereas the
actual bytes sent by the Win NT server is 2K btyes).
This is very strange to me.


+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.