Hi
when I try To send A small image less then 6 k over socket It's Ok but In big image I Received a corrupted file How can Resolve it ?
b4a code
delphi code
when I try To send A small image less then 6 k over socket It's Ok but In big image I Received a corrupted file How can Resolve it ?
b4a code
B4X:
If Successful Then
astream.Initialize(socket.InputStream,socket.OutputStream,"astream")
' astream.InitializePrefix(socket.InputStream,True,socket.OutputStream,"astream")
End If
Private Sub astream_NewData (Buffer() As Byte)
If File.Exists(File.DirRootExternal, "Pictures/1.jpg") Then
Dim Data() As Byte=Bit.InputStreamToBytes(File.OpenInput(File.DirRootExternal, "Pictures/1.jpg")) ' jpg 156 Ko
If astream.Write(Data) Then
Log(Data.Length)
End If
Else
Log("File Not Found")
End If
End Sub
B4X:
procedure TForm1.serverClientRead(Sender: TObject; Socket: TCustomWinSocket);
var
Stream: TStringStream;
begin
Stream := TStringStream.Create;
try
Stream.Position := 0;
Stream.WriteString(Socket.ReceiveText);
Stream.SaveToFile('D:\Received.jpg'); //jpg Received 6,66 Ko
finally
Stream.Free;
end;
end;
Last edited: