1 Attachment(s)
[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
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.
Re: Need Help! Winsock Transfer Data
Thankx man is there a way u can show me how to do it?
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:
'Use this like:
'SendPicture Winsock1, "C:\path\to\camera\image.jpeg"
Private Sub SendPicture(SocketObj As Object, FilePath As String)
Dim intFF As Integer, bytData() As Byte
'Get file handle to use.
intFF = FreeFile
'Open the file in binary read mode.
Open FilePath For Binary Access Read As #intFF
'Dump the file's data into bytData().
Get #intFF, 1, bytData()
Close #intFF 'Close the file.
'Send the data in one go.
If SocketObj.State = sckConnected Then
SocketObj.SendData bytData()
End If
'Clean up.
Erase bytData()
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"
Re: Need Help! Winsock Transfer Data
thankx that is helpfull on Image transfer