|
-
Nov 29th, 2002, 09:13 AM
#1
Thread Starter
Addicted Member
Sending Byte array via winsock??
Hi guys
Well I want to send a byte array via winsock but one problem…. I have the following in server app:
Winsock.SendData Bytearr
And the following in Dataarrival of the winscok in client:
Private Sub WinSock_DataArrival(ByVal bytesTotal As Long)
Dim b() As Byte
WinSock.GetData b
End Sub
Here is the problem: I want to send a 5000 byte thing so I have up to b(5000) right? Now I follow the process step by step in both server and client. I see while run time the server sends the whole bytearray at once but what about the client… here: I guess it creates a buffer and recives the array by part for example in 1000 byte packages. And every time for getting arriving bytes the DataArrival events wakes witch means loosing all other pervios bytes what should I do with it?
Thank u
-
Dec 27th, 2002, 05:48 AM
#2
Well ...
Try using a public array in your form/module, outside the Data_Arrival event, and keep appending the received bytes to this array.
.
-
Dec 27th, 2002, 08:15 AM
#3
Thread Starter
Addicted Member
Re: Well ...
Originally posted by honeybee
Try using a public array in your form/module, outside the Data_Arrival event, and keep appending the received bytes to this array.
.
I have tried to do this but:
firstly: we can't have a PUBLIC array in vb
secondly: the recived bytes are more than what i send i guess it's coz of TCP/IP appendings for packing and tracfering my larg data
-
Dec 27th, 2002, 09:56 AM
#4
Lively Member
I'm Having the exact same problem
Any Suggestions anyone?
-
Dec 27th, 2002, 10:02 AM
#5
Frenzied Member
In the Socket_Data_Arrival Event, make sure your Dimension the array to the bounds U want.
VB Code:
Private Sub WinSock_DataArrival(ByVal bytesTotal As Long)
Dim b(1 to 5000) As Byte
WinSock.GetData b
End Sub
HTH
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Dec 27th, 2002, 02:10 PM
#6
First of all, your array should be global (or static) on the receiving side, first you should tell the other app, how much you are about to send. Then send the data.
On the receiver side, get the length, store it in a long, then get the (chenked EDIT: Chunked) data, until it accumulated to the length that you are supposed to get. Then use the buffer.
But... if you want a simple solution, you can download the ActiveX I already made, that does what you need and more. The ActiveX also encrypts and compresses data, so it does more than you actually need. And plus that for every send you get a DataArrival event with ALL the data. And if you don't get the data once, the data is NOT lost... And if you send 1MByte 2 times, on the receiver size you will get only 2 events, and every one with 1MByte.
Just click on the link in my signature to get it. You will also find some documentation for it there.
Last edited by CVMichael; Dec 27th, 2002 at 03:08 PM.
-
Dec 27th, 2002, 02:54 PM
#7
Lively Member
NICE PROGRAM
Smart Socket is a very nice program, I LOVE IT it fixed my problem
lemme know when the next version comes out, i'd love to see those features that include bitmap and wav Compression
-
Dec 27th, 2002, 02:56 PM
#8
It will be a while...maybe weeks, or a month or two... it all depends on my free time.
-
Dec 27th, 2002, 03:12 PM
#9
The picture isn't missing
did you solve it? try:
Private Sub WinSock_DataArrival(ByVal bytesTotal As Long)
Dim b() As Byte
WinSock.GetData b, vbByte + vbArray
End Sub
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Dec 27th, 2002, 03:22 PM
#10
Lively Member
I was wondering if there was a function that switched a JPG to a byte array
I was using a Picture2Array Function, but it was buggy with an automation error, i already had that tlb that CVMichael told me to get in my other post:
http://www.vbforums.com/showthread.p...9&goto=newpost
But i still got an automation error, i went to Microsoft and they said the problem hasn't been solved for that error yet
I need to find a function that switches picture to array and array to picture
Any ideas??
Justin
-
Dec 27th, 2002, 03:24 PM
#11
It works perfectly on my computer...
"After you unzip the file copy the both type libraries to the Windows System folder and register them with regtlib.exe"
Did you do that ?
-
Dec 27th, 2002, 03:25 PM
#12
Lively Member
nah hold on lemme try that
-
Dec 27th, 2002, 03:27 PM
#13
Lively Member
wait i think im doing this wrong, how to you register them with regtlib.exe?
sry i've never done this
Justin
-
Dec 27th, 2002, 04:46 PM
#14
The picture isn't missing
find on the internet for the intel jpeg library, and also one of the tutorials that teaches you ho to use it. There is a function there to turn a picture object into a jpeg byte array, and the other way around so you don't need to save to jpg before sending.
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Dec 27th, 2002, 05:16 PM
#15
Lively Member
you mean use that instead of the functions im using?
-
Dec 27th, 2002, 05:36 PM
#16
Lively Member
Im having trouble finding a tutorial on Intel's JPEG Library
-
Dec 28th, 2002, 12:05 AM
#17
regtlib.exe should be on your computer, just do a search for that file in your C drive
I found it in C:\Windows
Open CMD or command ((DOS-prompt)depends what windows you use)
And I think you just type the command and file name i.e.
regtlib olelib.tlb
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|