Results 1 to 17 of 17

Thread: Sending Byte array via winsock??

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163

    Question 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

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Try using a public array in your form/module, outside the Data_Arrival event, and keep appending the received bytes to this array.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163

    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

  4. #4
    Lively Member
    Join Date
    Dec 2002
    Posts
    107
    I'm Having the exact same problem

    Any Suggestions anyone?

  5. #5
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    In the Socket_Data_Arrival Event, make sure your Dimension the array to the bounds U want.
    VB Code:
    1. Private Sub WinSock_DataArrival(ByVal bytesTotal As Long)
    2.  
    3. Dim b(1 to 5000) As Byte
    4.  
    5. WinSock.GetData b
    6.  
    7. End Sub

    HTH

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  6. #6
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    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.

  7. #7
    Lively Member
    Join Date
    Dec 2002
    Posts
    107

    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

  8. #8
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    It will be a while...maybe weeks, or a month or two... it all depends on my free time.

  9. #9
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    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 .

  10. #10
    Lively Member
    Join Date
    Dec 2002
    Posts
    107
    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

  11. #11
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    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 ?

  12. #12
    Lively Member
    Join Date
    Dec 2002
    Posts
    107
    nah hold on lemme try that

  13. #13
    Lively Member
    Join Date
    Dec 2002
    Posts
    107
    wait i think im doing this wrong, how to you register them with regtlib.exe?

    sry i've never done this

    Justin

  14. #14
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    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 .

  15. #15
    Lively Member
    Join Date
    Dec 2002
    Posts
    107
    you mean use that instead of the functions im using?

  16. #16
    Lively Member
    Join Date
    Dec 2002
    Posts
    107
    Im having trouble finding a tutorial on Intel's JPEG Library

  17. #17
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    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
  •  



Click Here to Expand Forum to Full Width