From: Scott Klement

If you're reading into an RPG VARYING field you need to follow these
steps:

a) Set the field to it's maximum length before calling the recv() API.
Generally the code to do that looks like this:

%len(Field) = %size(Field) - 2;

Please realize that the magic number "2" may change in a future release of
the compiler. No need to rehash the entire discussion, but once VARYING
fields great than 64K are allowed, you may need to adjust this code. I hope
that the compiler folks will make sure that you can specify your D-specs in
such a way that existing code doesn't break.


b) Call the recv() API, but pass the address of the DATA, not the
address of the length. Basically, add 2 to the adddress. Typically,
you'd code it as follows:

len = recv(mySock: %addr(Field)+2: %len(Field): 0);

This is another place where the value 2 is only good "for now".


Also, I believe you can skip step A and just do this:

len = recv(mySock: %addr(Field)+2: %size(Field)-2: 0);

This way, you remove one line of code and you have the magic number two
isolated in one line.


Joe



This thread ...

Follow-Ups:
Replies:

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

This mailing list archive is Copyright 1997-2026 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.