winapi
Mar 13th, 2000, 08:22 AM
Hi,
I'm developing an application for work which need to capture the screen every secone on a computer and send the picture file via winsock to a server program. I have the screen capture working perfectly, but the sending is the problem. On the client computer, I capture the screen and send the file in a timer. It works good for the frst frame, but every other frame afterwards never updates the server. I think my problem is in the file transfer.Ususally working with files you need to close the file after the transfer is complete,but I don;t know how to tell when the file is complete. I tried to add a wsock1.senddata "DONE" after the send file is complete to test for, but this never seems to get through. Can someone please explain to me how to write a program to transfer a file everytime the timer hits.
I got this code from here in the demos section, and it gives the same results.
Public Sub SendFile(FileName As String, wsock2 As Winsock)
Dim FreeF As Integer
Dim LocData() As Byte
Dim LenData As Long
Dim sendloop As Long
DoEvents
FreeF = FreeFile
Open FileName For Binary As #FreeF ' Open file
ReDim LocData(1 To 30720) As Byte ' Work in 2kb chunks
LenData = LOF(FreeF) ' Get length of file
For sendloop = 1 To LenData \ 30720 ' Go through file
Get #FreeF, , LocData 'Get data from the file nCnt is from where to start the get
wsock2.SendData LocData 'Send the chunk
Next
If LenData Mod 30720 <> 0 Then ' If there is any left over at the end
ReDim LocData(1 To LenData Mod 30720) As Byte ' Clear up the leftovers
Get #FreeF, , LocData 'Get data from the file nCnt is from where to start the get
wsock2.SendData LocData 'Send the chunk
End If
Close #FreeF ' Close the file
Server.wsock2.SendData "DONE"
Sleep 200 ' Let computer catch up
End Sub
Edited by winapi on 03-13-2000 at 09:23 PM
I'm developing an application for work which need to capture the screen every secone on a computer and send the picture file via winsock to a server program. I have the screen capture working perfectly, but the sending is the problem. On the client computer, I capture the screen and send the file in a timer. It works good for the frst frame, but every other frame afterwards never updates the server. I think my problem is in the file transfer.Ususally working with files you need to close the file after the transfer is complete,but I don;t know how to tell when the file is complete. I tried to add a wsock1.senddata "DONE" after the send file is complete to test for, but this never seems to get through. Can someone please explain to me how to write a program to transfer a file everytime the timer hits.
I got this code from here in the demos section, and it gives the same results.
Public Sub SendFile(FileName As String, wsock2 As Winsock)
Dim FreeF As Integer
Dim LocData() As Byte
Dim LenData As Long
Dim sendloop As Long
DoEvents
FreeF = FreeFile
Open FileName For Binary As #FreeF ' Open file
ReDim LocData(1 To 30720) As Byte ' Work in 2kb chunks
LenData = LOF(FreeF) ' Get length of file
For sendloop = 1 To LenData \ 30720 ' Go through file
Get #FreeF, , LocData 'Get data from the file nCnt is from where to start the get
wsock2.SendData LocData 'Send the chunk
Next
If LenData Mod 30720 <> 0 Then ' If there is any left over at the end
ReDim LocData(1 To LenData Mod 30720) As Byte ' Clear up the leftovers
Get #FreeF, , LocData 'Get data from the file nCnt is from where to start the get
wsock2.SendData LocData 'Send the chunk
End If
Close #FreeF ' Close the file
Server.wsock2.SendData "DONE"
Sleep 200 ' Let computer catch up
End Sub
Edited by winapi on 03-13-2000 at 09:23 PM