De applicatie die ik aan het ontwikkelen ben, verstuurd een file van een VB6 applicaties over sockets naar een .NET applicatie.
Het probleem is echter dat de .NET applicatie de data pas gaat parsen op het moment dat ik de verbinding van de VB6 applicatie sluit.
Stuk VB6 code die de file verstuurt:
Stuk .NET code
Moet de data die verstuurd wordt vanuit VB geterminate worden ofzo?
Iemand enig idee wat het probleem kan zijn?
Het probleem is echter dat de .NET applicatie de data pas gaat parsen op het moment dat ik de verbinding van de VB6 applicatie sluit.
Stuk VB6 code die de file verstuurt:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
| ' Open the file that we're sending, for BINARY mode. This means that we can
' read out bits regardless of what's in the file (text, image, music etc..).
hFile = FreeFile
Open strFilePath For Binary As #hFile
' We need to read the next unsent piece of the file, so move through the
' file past all the bits we've already sent. Then, when we read into
' strData, the data will be the next consecutive bytes.
If (lngFilePos = 0) Then lngFilePos = 1
Seek hFile, lngFilePos
' Work out how large this chunk is going to be. Normally, it will be the
' standard CHUNK_SIZE, but if the last piece is less than that, decrease it.
lngChunkSize = LOF(hFile) + 1 - lngFilePos
If (lngChunkSize > CHUNK_SIZE) Then lngChunkSize = CHUNK_SIZE
' If the chunksize was 0, it means there's no data left to send, so our
' transfer is complete.
If (lngChunkSize = 0) Then
' Send the EOF marker so the remote host knows that's all the data.
strData = "EOF" & vbNewLine
Else
' Grab the data from the file, and increment our file pointer so that next
' time we read, we are reading the next piece of the file.
strData = String$(lngChunkSize, 0)
Get #hFile, , strData
lngFilePos = lngFilePos + lngChunkSize
End If
'send the data to the server
Call objServerSocket.SendData(strData)
DoEvents
'close the file we where reading from.
Close #hFile |
Stuk .NET code
code:
1
2
3
| int ChunkBytesSize = 3072;
BinaryReader StreamReader;
byte[] receivedBytes = StreamReader.ReadBytes(ChunkBytesSize); |
Moet de data die verstuurd wordt vanuit VB geterminate worden ofzo?
Iemand enig idee wat het probleem kan zijn?