PDA

Click to See Complete Forum and Search --> : Fetch large data with GetData, mswinsck.ocx


SocketSolutions
Oct 27th, 2000, 01:30 PM
I am trying to receive a large block of data, but
it never seams to be larger than 512bytes when
received.

Im working on a server that uses mswinsck.ocx, and
the client is passing a simple text file that has
a binary file embedded (attachment) in it using
Base64 (Or UU). The sent text document should
be at least 64K, since the attached graphic is at
least that large. However, when I open to write
the file or get a Len, what was received is only
512bytes. Ive never seen this happen before, maybe
I need to do something different?

This is just a snippit, but shows the general
operation:

winsock(index).ReceiveData

dim InBuffer as string

winsock(1).GetData InBuffer

open "c:\test.msg" for output as #1
print #1, InBUffer
Close #1

test.msg is only 512bytes, and also len(InBUffer)
returns 512!

Any ideas anyone? I need InBuffer to be a string,
since I will be doing some string manipulation
with it, I have to parse some headers from it, as
this is an NNTPd in development, and the newsgroup
the message belongs in, etc.. is in the message.

Thanks,
Andrew

ccoder
Oct 27th, 2000, 02:18 PM
I'm not familiar with the ReceiveData method and could not find it searching the MSDN site.

I'm curious about your indices. Does index = 1 in the following?

winsock(index).ReceiveData

dim InBuffer as string

winsock(1).GetData InBuffer

Is this code in your DataArrival routine and, if so, what is the value of bytesTotal?

oetje
Oct 28th, 2000, 02:50 AM
Maybe you must send the file in pieces of 512 bytes.

ccoder
Oct 28th, 2000, 02:49 PM
Or perhaps 512 bytes is the default if you don't specify the number of bytes in the GetData call. Just a guess as I have never tried to retrieve data with specifying the length.

KnIgHt
Nov 1st, 2000, 04:41 PM
um....I'm working on two programs write now...a client and a server.....the problem i'm having is getting the server to host multiple clients connected to it....if you could help me out with that, it would be great.

but for your problem what you should do is if the file is bigger than the variable can hold just put all the information from the variable into a file everytime it gets full and keep doing it untill the file is complete.

-knight
-icq 17743984

Nov 2nd, 2000, 01:15 AM
Your receive code:


winsock(index).ReceiveData

dim InBuffer as string

winsock(1).GetData InBuffer

open "c:\test.msg" for output as #1
print #1, InBUffer
Close #1


Assumes that the sent file is all sent at once, however this is not the case when you use Winsock. When sending large files with Winsock you will find that the file is broken into smaller packets which are then individually sent. Thus, by writing to the file in output mode, the previously received data are wiped over by the new one, and eventually by the last packet.

To solve the problem you can try to open the file in append mode (not sure if it'll work), or at the sending end break the file into your own little packets which have a predetermined size so that the receiving end will know what sized packets to expect.

Sunny