Sockets - send()
Nancy Palmquist
nlp at vss3.com
Thu Oct 30 16:04:36 PDT 2008
Kenneth Brody wrote:
> Quoting Nancy Palmquist (Thu, 30 Oct 2008 18:02:31 -0400):
>
>> Anyone using the sockets logic in filePro, I was wondering if anyone
>> had an idea about this.
> [... sends 4000 bytes through socket, but recv's 1490 on the other end...]
>> rx(4000)=""
>> length=recv(accept_handle,rx)
>>
>> If I display the value of LENGTH, it will show "1490" and I am
>> missing the end of my file.
> [...]
>> Any suggestions would be helpful. All the records that are smaller
>> than 1490
>> seem to work flawlessly.
>
> It's a part of the TCP/IP design that messages can be broken up into
> smaller chunks, which can be reassembled at the other end. In you call
> recv() for a length of 4000 before they have all arrived on the other
> end, recv() can return just the part that has been received. If you
> call recv() again, you'll get the next chunk that comes, and so on.
>
> In this case, it appears that the connection has been set to break things
> up into 1490-byte chunks. (If you check your network settings, you will
> probably see an "MTU" value of 1500.)
>
> As I recall, filePro's RECV() function has a flag to tell it to wait until
> the entire length has been received (or an error occurs), but I'm not in
> front of a system where I can check how to pass it.
>
I looked in my docs for sockets and do not see anything more than ,flags in the
descriptions. (From the on-line manual)
status = RECV(handle,dest [ ,len [ ,flags [ ,noblock ]]] )
status = RECVLINE(handle,dest [ ,len [ ,flags [ ,noblock ]]] )
Receive a message from a connected socket. Fills in the field in "dest" with the
result. Returns the number of characters received, or a negative number
containing the error number. A maximum of "len" characters will be read.
RECVLINE() will read up to len characters, or until a new line character is
received. The new line character, if any, will be discarded for RECVLINE().
"Len" defaults to the length of the destination field. "Flags" defaults to zero
and should currently not be given any other value. "Noblock" defaults to zero.
It a non-zero value is passed, the function will return immediately, even if
less than "len" bytes are received.
So I guess ,flags is not functioning yet.
How would you make it cycle around?
Would it look like this
again:
then: length=recv(accept_handle,rx)
if: total_length lt "4000"
then: line=line{rx;tot_length=total_length+length;goto again
Or should I force it to get it in pieces by making rx(1000) and repeating recv()
4 times.
NOW line would have all the stuff that was sent, am I right???
Nancy
--
Nancy Palmquist MOS & filePro Training Available
Virtual Software Systems Web Based Training and Consulting
PHONE: (412) 835-9417 Web site: http://www.vss3.com
More information about the Filepro-list
mailing list