Results 1 to 5 of 5

Thread: [RESOLVED] Need Help! Winsock Transfer Data

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    148

    Resolved [RESOLVED] Need Help! Winsock Transfer Data

    Hey guys! I'm making a WebCam Server and Client

    First I capture Picture from the Cam and Save into HD JPG format.

    then load picture with in a String and Send to Client.

    but some Character are bad with send through Winsock in diff Lang. Windows OS.

    here is a lil example i made with commview screenshot.

    Thank for your help
    Attached Files Attached Files

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Need Help! Winsock Transfer Data

    The 2 bytes you circled on the screenshot are Chr$(0) Chr$(0) (I think, could be wrong).

    I wouldn't send the picture data as a string, I'd send it as a byte array since it is binary data.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    148

    Re: Need Help! Winsock Transfer Data

    Thankx man is there a way u can show me how to do it?

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Need Help! Winsock Transfer Data

    It's best to send the file piece by piece, but I'm assuming since it's a webcam image (and also converted to JPEG) then you should be able to send the whole thing at once since it's probably real small.

    Here's the most basic code I can think of to send the file:

    vb Code:
    1. 'Use this like:
    2. 'SendPicture Winsock1, "C:\path\to\camera\image.jpeg"
    3. Private Sub SendPicture(SocketObj As Object, FilePath As String)
    4.     Dim intFF As Integer, bytData() As Byte
    5.    
    6.     'Get file handle to use.
    7.     intFF = FreeFile
    8.    
    9.     'Open the file in binary read mode.
    10.     Open FilePath For Binary Access Read As #intFF
    11.         'Dump the file's data into bytData().
    12.         Get #intFF, 1, bytData()
    13.     Close #intFF 'Close the file.
    14.    
    15.     'Send the data in one go.
    16.     If SocketObj.State = sckConnected Then
    17.         SocketObj.SendData bytData()
    18.     End If
    19.    
    20.     'Clean up.
    21.     Erase bytData()
    22. End Sub

    I'd only use it as an example though. It's best to send something before the file data and after it so the receiving end knows where it starts and where it ends, ie:

    "START" [File data here] "END"

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    148

    Re: Need Help! Winsock Transfer Data

    thankx that is helpfull on Image transfer

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