THAErAsEr Posted August 13, 2012 Posted August 13, 2012 Hi all, I'm currently working on a server-client script for sending files over the network(LAN) and after that, I can remotly run them or whatever. Now I got this all working, but now during testing, I start to see that sometimes the program 'loses' some bytes on bigger files (10MB+). My guess is that this is possible because of other traffic on the network? If I'm wrong, can anyone provide me with an explanation for this? If I'm right, can anyone push me in the direction of how to avoid these losses? If more info, codes, explenation is needed, please ask Thank you, Wesley
RedneckTech Posted August 13, 2012 Posted August 13, 2012 When you say "loses some bytes on bigger files" is any information being lost, or is file size changing with no lost functionality? I ask because I have seen this when changing between windows versions (win7 moving files to server 2003) the files will get smaller when sent to the older OS because there are less available file attributes. If this is the case you may want to look into calling the "Robocopy" command in your script rather than using FileCopy() as its very good at pulling all attributes associated with a file (even between OS versions)
THAErAsEr Posted August 13, 2012 Author Posted August 13, 2012 (edited) Hi, thanks for the answer. -It also loses it's functionality. I got PDF's that I can't open anymore, another PDF where the front page is empty, a ZIP file that says: Error: unable to process the headers in the archive. -It's not like it loses 1 byte / MB or so. It's random. Check the screenshots for more info. 1st picture: 1st try 2nd picture: 2nd try 3rd picture: original size of files Edited August 13, 2012 by THAErAsEr
RedneckTech Posted August 13, 2012 Posted August 13, 2012 I cant help ya then. im still kinda nooby myself and dont understand the inner workings of autoIT file limits and the like. may be something with max file size of a file?
Moderators JLogan3o13 Posted August 13, 2012 Moderators Posted August 13, 2012 If more info, codes, explenation is needed, please ask Thank you,WesleyHi, THAErAsEr, welcome to the forum. I will offer that it is always a good idea to provide code when requesting assistance, either your complete code or a short reproducer. You will always receive more help if forum members have code to go through. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
guinness Posted August 13, 2012 Posted August 13, 2012 I'm sure I have seen a post around the forum before about this topic. Search _SendFile or something similar. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
THAErAsEr Posted August 14, 2012 Author Posted August 14, 2012 It does not accept my screenshot :/ @guinness, do they mention this problem too? Because I allready looked trough some of the _SendFile and TCP scripts allready. It does not look like a coding problem, because sending the same file over and over again, keeps getting me different file sizes. But that's just my idea offcourse Code: Client code for sending messages and files: expandcollapse popupFunc SendMessage($sendType, $sendMessage) ;Type selection Select Case $sendType="#MSG#" $sendTypeLabel="MSG > " Case $sendType="#CMD#" $sendTypeLabel="CMD > " Case $sendType="#SAF#" $sendTypeLabel="File Transfer : " $sendFileHandler=FileOpen($sendFile, 16) EditControl($sendTypeLabel, $sendMessage) $sendFileBinary=Binary("#SAF#" & StringTrimLeft($sendFile, StringInStr($sendFile, "\", 2, -1))&"," & FileRead($sendFile) & "#/SAF#") ;EditControl("TEST > ", $sendFileBinary) ;TESTING ;EditControl("TEST > ", "#SAF#" & StringTrimLeft($sendFile, StringInStr($sendFile, "\", 2, -1))&"," & FileRead($sendFile) & "#/SAF#") ;TESTING FileClose($sendFile) $sendFileBinaryStart=BinaryLen($sendFileBinary) While BinaryLen($sendFileBinary) $temptest=$temptest+1 $sendBytes = TCPSend($startConnect, $sendFileBinary) If @error Then MsgBox(16, "Error", "Failed to send file.") GUICtrlSetData($GUIControlIDProgress, $temptest) ; BinaryLen($sendFileBinary) / $sendFileBinaryStart $sendFileBinary = BinaryMid ($sendFileBinary, $sendBytes + 1, BinaryLen ($sendFileBinary) - $sendBytes) WEnd GUICtrlSetData($GUIControlIDProgress, 0) EndSelect If $sendType<>"#SAF#" then ;Input control $sendMessage=$sendMessage TCPSend($startConnect, StringToBinary($sendType & $sendMessage, 4)) EndIf ;GUI handling If $sendMessage<>"" And $sendType <> "#SAF#" Then EditControl($sendTypeLabel, $sendMessage) ElseIf $sendType = "#SAF#" Then EditControl($sendTypeLabel, "Completed.") EndIf ControlFocus("My Cliënt", "", 4) EndFunc Server code for receiving the message/file: expandcollapse popupFunc receiveData($repeat = False) $recBinary=TCPRecv($connectedSocket,2048) If $recBinary <> "" Then ;rtf(BinaryToString($recBinary) & " = " & StringToBinary($recBinary)) If $repeat = False Then readMessage($recBinary) Else return($recBinary) EndIf EndIf EndFunc Func GUILoop() While 1 $GUIMsg=GUIGetMsg() Select Case $GUIMsg=$GUI_EVENT_CLOSE Exit EndSelect receiveData() WEnd EndFunc Func readMessage($recBinary2) $recString=BinaryToString($recBinary2, 4) $recType=StringLeft($recString,5) $recMessage=StringMid($recString, 6) Select Case $recType="#MSG#" $recTypeLabel="MSG > " Case $recType="#CMD#" $recTypeLabel="CMD > " If ProcessExists("cmd.exe") = 0 Then Run("cmd.bat") Else WinActivate("Remote CMD") EndIf Sleep(50) Send($recMessage) Send("{ENTER}") Case $recType="#SAF#" $recTypeLabel="File Transfer : " $fileArray = StringSplit($recMessage, ",") $fileTitle=$fileArray[1] $recMessage = $fileArray[2] While 1 $endPosition=StringInStr($recMessage, "#/SAF#", 0, -1) if $endPosition > 0 Then $recMessage=StringTrimRight($recMessage, 6) $endFound=True EndIf $recBuffer&=$recMessage If $endFound Then ExitLoop $recMessage=BinaryToString(receiveData($repeat)) WEnd writeFile($fileLocation, $fileTitle, $recBuffer) EndSelect If $recMessage <> "" And $recType <> "#SAF#" Then EditControl($recTypeLabel, $recMessage) ElseIf $recType = "#SAF#" Then EditControl($recTypeLabel, $fileTitle & " saved at " & $fileLocation & ".") Endif ;Clear vars $recBuffer = "" $recMessage = "" $recString = "" $recTypeLabel = "" $recType = "" $fileTitle = "" ;$fileLocation = "" ;constante $fileArray = "" $endFound = False $endPosition = "" EndFunc Func writeFile($fileLocation, $fileTitle, $fileData, $writeMode=$writeModeErase) $fileHandle=FileOpen($fileLocation & $fileTitle, $writeMode) FileWrite($fileHandle, $fileData) FileClose($fileHandle) EndFunc Thank you all allready!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now