borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Mutli Threading with Winsock API)Next Topic (Help me.....) New Topic New Poll Post Reply
AndreaVB Forum : Network : Winsock/Binary
Poster Message
kanie
Level: Guest


icon Winsock/Binary

Hi,
I was searching for some help with binary eading a bitmap for sending over
winsock and found this forum.

I wonder if anyone could help me here?
(applogies for '>' characters, this was also an email)
My aim is to read a file to a string with binary access then send it with a
winsock, but if the filesize is over 1024 to read it a chunk at a time.
Here is some code of where I got up to, I would really appreciate any help
you could give.

             Open "C:dump.jpg" For Binary Access Read As #1  '  This is the
> image
>                If LOF(1) < ChunkSize Then     ' If the file is less than 1k
> then read in with one go
>                     sck.SendData Input(LOF(1), 1) ' Send the data directly
> after reading
>                     Close #1  ' Close the file
>                     MsgBox "Transfer is lower than 1 k"  ' For debugging
> purposes
>                Else
>                     MsgBox "Transfer over 1 k"   ' For debugging purposes
>                     Close #1 ' Check files are closed
>                     Close #2 ' Check files are closed (this is a loopback to
> test binary reading is functioning)
>                     Open "c:screen.jpg" For Binary As #1 'Source
>                     Open "c:local.jpg" For Binary As #2 'Local write (for
> debugging)
>                     Do Until LOF(1) = Loc(1) Or EOF(1)
>                         file = ""
>                         'MsgBox LOF(1) & vbTab & Loc(1) & vbTab & LOF(1) -
> Loc(1) ' How much of the file is read
>                         If LOF(1) - Loc(1) < ChunkSize Then
>                             'If there is not enough data left for one chunk.
>                             file = String(LOF(1) - Loc(1), 0)
>                             'Sets the length of the string; Data.
>                         Else
>                             'If there is enough data left for one chunk
>                             file = String(ChunkSize, 0)
>                         End If
>                     Get #1, , file
>                     Put #2, , file
>                   Loop
>                 Close #1
>                 Close #2
>
>                 sck.SendData file
>

Thanks in advance,
Kanie

:

[Edited by admin on 16-09-2002 at 10:16 AM GMT]

16-09-2002 at 07:03 AM
| Quote Reply
AndreaVB Forum : Network : Winsock/Binary
Previous Topic (Mutli Threading with Winsock API)Next Topic (Help me.....) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder