Thank you my friend, I ll think about it :) I ll test this property called DataAvaible. Bye and really thank you.
unrealed
Posts
-
File Transfer -
File TransferIts working now, I had to modify my code: Server:
... NS.Write(Packet,0,Packet.Length); NS.Flush(); Thread.Sleep(5); CurrentSize += PacketSize; ...
Client:... NS.Read(Packet,0,Packet.Length); NS.Flush(); Thread.Sleep(5); CurrentSize += PacketSize; ...
How ever, maybe 5 MS wont be enough, maybe 5 MS will be more than enough... Is there a METHOD to wait until the CLIENT receive all the packet? like: NS.Wait(); Thank you. -- modified at 11:31 Sunday 5th March, 2006 -
File TransferHello my friend, thank you very much, I tryed to hex the 2 files, look what happens: Real File: $121C ... 3B 00 CE 8B BE FE ... Downloaded File: $121C ... 3B 00 00 00 00 00 .... CE 8B BE FE ... Its like add '00 00 00 etc' in the mid of file. I am verifying right now if the CLIENT BUFFER is bigger than the packet, I ll check whats going on. Thank you for the help. if you know whats wrong, tell me, thx!
-
File TransferHello everybody, I tryed to make a software that check for updates: Client: Login ( username , password ) , Receive update list , request updating files , get files , execute another process. Server: Receive login , login on data-base if possible , send update list if logged , send requested files , logout. Everythings are done, if I run CLIENT and SERVER on local computer, everythings works fine, but if I run SERVER on my computer, and CLIENT in another computer, the UPDATE doesnt work fine. What happens: Server can send any Text file good, in perfect state, but if I send binary files like JPG images, EXE, or any other things that arent TEXT FILES, it sends wrong BYTES, like if server is encoding all bytes to TEXT format... === CLIENT GET FILE VOID:
//Private Void: private void GetFile ( int FileNumber ) { string FilePath = UpdateFileList[FileNumber]; long FileSize = UpdateSizeList[FileNumber]; long CurrentSize = 0; if ( FilePath.IndexOf("\\") > 0 ) { string newDirectory = FilePath.Substring(0,FilePath.IndexOf("\\")); if ( !Directory.Exists(newDirectory) ) Directory.CreateDirectory(newDirectory); } FileStream FS = new FileStream(FilePath,FileMode.Create,FileAccess.Write); while ( CurrentSize < FileSize ) { try { this.Stats_Text.Text = "Downloading updatings ( " + (FileNumber+1) + " / " + UpdateFileList.Length + " )\n" + FilePath + " ( " + Convert.ToByte((Convert.ToDouble(CurrentSize)/Convert.ToDouble(FileSize))*100) + " % completed of " + (FileSize/1024) + " KBs )"; long PacketSize = FileSize-CurrentSize; if ( PacketSize > 128 ) PacketSize = 128; byte[] Packet = new byte[PacketSize]; NS.Read(Packet,0,Packet.Length); NS.Flush(); FS.Write(Packet,0,Packet.Length); FS.Flush(); CurrentSize += PacketSize; FS.Seek(CurrentSize,SeekOrigin.Begin); } catch { try { File.Delete(FilePath); } catch {} this.Stats_Text.Text = "The connection with the Server was lost"; Disconnect(); } } FS.Close(); }
=== SERVER SEND FILE VOID://Private Void: private void SendFile ( int FileNumber ) { Console.Write("US - Sending updating file : " + (FileNumber+1) + " / " + Owner.UpdateFileList.Length + " [ " + ClientUserName + " ]\n"); string FilePath = Owner.UpdateFileList[FileNumber]; long FileSize = Owner.UpdateSizeList[FileNumber]; long CurrentSize = 0; FileStream FS = new FileStream(FilePath,FileMode.Open,FileAccess.Read);