GtaSpider Posted May 21, 2007 Posted May 21, 2007 Hi everyone IMPORTANT: You have to use autoit version 3.2.4.5 or higher!All of you know: its thanks autoit 3.2.4.x very easy to send File over TCP.. now I've written a UDF called _FileSend and _FileReceive_FileSendexpandcollapse popup#include-once ;=============================================================================== ; ; Function Name: _FileSend ; Description:: Sending a File to an Server (See _FileReceive) ; Parameter(s): ;$sFile : The File to send ;$IP : The target IP Adress ;$PORT [Optional] : The Port to use (must be the same as by _FileRecevie!!) ;$iSplash [Optional] : 1(defaul) = show SplashText ; 0 = dont show SplashText ;$iWaitWhileConnected [Optional] : 0 = If TCPConnect faild (@error) Return with error Code 2 ; 1(Default) = If TCPConnect faild put it in a while until connected ; Requirement(s): - ; Return Value(s): On Succes Return 1 ; On faild Return -1 and @error code 1-3: ; @error = 1: File not exist ; @error = 2: TCPConnect faild (only able if $iWaitWhileConnected <> 1) ; @error = 3: Faild to Open File ; @error = 4: A Connectionproblem while sending ; Author(s): GtaSpider ; ;=============================================================================== Func _FileSend($sFile, $IP, $PORT = 4324,$iSplash=1, $iWaitWhileConnected = 1) Local $iMainSocket = -1, $sBuff, $iFileOp,$sRecv If Not FileExists($sFile) Then Return SetError(1,0,-1) If $iSplash Then $iSplash = SplashTextOn('','Try To Connect...',200,20,-1,-1,1) TCPStartup() If Number($iWaitWhileConnected) = 1 Then While $iMainSocket = -1 $iMainSocket = TCPConnect($IP, $PORT) WEnd Else $iMainSocket = TCPConnect($IP, $PORT) If @error Then Return SetError(2, 0, -1) EndIf If $iSplash Then ControlSetText($iSplash,'','Static1','Read File...') $iFileOp = FileOpen($sFile, 16) If @error Then Return SetError(3,0,-1) $sBuff = Binary(StringTrimLeft($sFile,StringInStr($sFile,"\",-1,-1))&",")&FileRead($iFileOp) FileClose($iFileOp) If $iSplash Then ControlSetText($iSplash,'','Static1','Sending File...') While BinaryLen($sBuff) $iSendReturn = TCPSend($iMainSocket, $sBuff) If @error Then Return SetError(4, 0, -1) TrayTip('',$iSendReturn,1) $sBuff = BinaryMid ($sBuff, $iSendReturn + 1, BinaryLen ($sBuff) - $iSendReturn) WEnd If $iSplash Then ControlSetText($iSplash,'','Static1','Succesfull!') TCPCloseSocket($iMainSocket) TCPShutdown() Sleep(1000) SplashOff() Return 1 EndFuncoÝ÷ Ù8^)^IéÝ~éܱéݱ§âëhjÇ«½êÓábä^qè¯yû§r·½§âçë¢f'§´Z+Þwè®fì涮uû¶êr¢çmºÇ¢Ønuýý²Ì§rè+&¢z'zÇ+DÅ©©ë)^Iéݦ¦W¿m«¢+Ù}¥±M¹¡]¥¹½ÝͥȵÀìÅÕ½ÐìÀäÈíµ¹áÅÕ½Ðì±%AÉÍÌĤíM¹Ð¥Ñ¤µ¹á¸¥%@ÉÍÍ%AÉÍÌÄ¡±Í¼¸¥¥¹¤)%ÉɽÈQ¡¸5Í ½à Ðà°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíÉɽÈèÅÕ½ÐìµÀíÉɽȤ)}¥±M¹¡]¥¹½ÝͥȵÀìÅÕ½ÐìÀäÈíµ¹áÅÕ½Ðì°ÅÕ½ÐìÄäȸÄØà¸À¸ÄÅÕ½Ðì°ÐÐÐаÀ°À¤íM¹Ð¥Ñ¤µ¹á¸¥%@ÉÍÍÄäȸÄØà¸À¸ÄñÈÁ½ÉÐÐÐÐаMÁ±Í¡ÑáÐݥɹ¥¡Ð¹é¥Ðչݹ¸È¥´ÉÍѸµ° ½¹¹Ñ¸¡±Í¡³ÐÉ¥¡Ðȸ)%ÉɽÈQ¡¸5Í ½à Ðà°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíÉɽÈèÅÕ½ÐìµÀíÉɽÈoÝ÷ Ù±bä^qè¯xLZ^ý¶®¶seôfÆU&V6VfRµ7V6W'BFRFFVÖBFVÒ÷&væÂæÖVâ"ÂFR7BG&W73Â÷'B7BC3#BVæBFW"7Æ6FWBv&BvW¦Vw@¤bW'&÷"FVâ×6t&÷CÂgV÷C²gV÷C²ÂgV÷C´W'&÷#¢gV÷C²f×´W'&÷"¥ôfÆU&V6VfRgV÷C´VæTFFVæWRgV÷C²ÂgV÷C³"ãcããgV÷C²ÃCCCBõ7V6W'BFRFFVÖBFVÒæÖVâgV÷C´VæTFFVæWRgV÷C²"ÂFR7B"ãcããÂFW"÷'B7BCCCBVæBFW"7Æ6FWBv&Bæ6BævW¦Vw@¤bW'&÷"FVâ×6t&÷CÂgV÷C²gV÷C²ÂgV÷C´W'&÷#¢gV÷C²f×´W'&÷"please for comments and bugreports Mfg / Best Regards Spider www.AutoIt.de - Moderator of the German AutoIt Forum
lsakizada Posted May 22, 2007 Posted May 22, 2007 IMPORTANT: You have to use autoit version 3.2.4.5 or higher!no such version yet .. man. Parent Directory - Au3Info.exe 18-May-2007 01:21 97K AutoIt3_x64.exe 20-May-2007 15:00 670K SciTEUser.properties 28-Apr-2007 08:12 1.6K autoit-v3.2.3.14-beta-setup.exe 06-May-2007 06:27 3.8M autoit-v3.2.3.14.zip 06-May-2007 06:29 5.6M docs/ 25-Jun-2006 11:34 - pcretest.exe 02-Oct-2006 16:16 184K sav/ 09-May-2007 02:45 - undocumented/ 20-Dec-2006 03:41 - Be Green Now or Never (BGNN)!
GtaSpider Posted May 22, 2007 Author Posted May 22, 2007 HelloThanks for comments @lsakizada: uhm? 3.2.4.6 relased as stable...: autoit-v3.2.4.6-setup.exe@poisonkiller: Thanks Mfg / Best Reagards Spidr www.AutoIt.de - Moderator of the German AutoIt Forum
Obi-w00t Posted May 22, 2007 Posted May 22, 2007 Very nice work, this seems to be one of the things people always want to know about with TCP.
GtaSpider Posted May 23, 2007 Author Posted May 23, 2007 Hello Obi. Thank you for this comment If someone need help to understanding the script can i doo it, but (maybe you see^^) my english is not the best ;-) But i will do what possible for me Mfg / Bes Regards Spider www.AutoIt.de - Moderator of the German AutoIt Forum
emoyasha Posted January 17, 2008 Posted January 17, 2008 i want to send files over my messenger client. u want a user to be able to press a button and a gui show up with the with ip and port to send to' then the other user open a box and put the ip and port to receive from how would i do this Spoiler Admin Of:http://notmyspace.info [Under Development, looking for volunteers to help improve]http://PSNetCards.co.ukhttp://ZacnAndLindsey.com [Under development, not quite sure what to do with it yet]http://revelm.com------------------------------------Radio Streams:http://75.185.53.88:8000 [128kb/s 44kHz]http://75.185.53.88:8002 [22kb/s 22kHz](works on mobile phones)-----------------------------------My Server:Owned By: http://jumpline.comIP:66.84.19.220Bandwidth:200GBStorage Space:1TBNetwork Connection: 1GB/S[up and down]Operating System: Red Hat LinuxInstalled Apps:Webmail, phpBB, Majordomo, phpMyAdmin, MySQL, Active Server Pages, FrontPage Extensions 2002, GraphicsMagick, Mod Perl, Perl, PHP: Hypertext Preprocessor, Python(want cheap good webhosting, or need a place to park your domain? contact me)-----------------------------------
Synapse Posted January 17, 2008 Posted January 17, 2008 Thx man...I was searching for a long time for something like this... Nice work.... 10+
PhilRip Posted January 18, 2008 Posted January 18, 2008 Thx man...I was searching for a long time for something like this...Nice work.... 10+
MetalSpongebob Posted January 18, 2008 Posted January 18, 2008 (edited) Very great work man! It's also usefull to learn something more of the tcp protocol Congratulations Edited January 18, 2008 by MetalSpongebob Noob but ethical
GtaSpider Posted January 18, 2008 Author Posted January 18, 2008 HelloThank you for Replies! It makes me lucky, that im not the only one how need this function @emoyasha:I've written you smth.. i hope this could help:Serverexpandcollapse popup#include <GUIConstants.au3> $rcvGui = GUICreate("Server - Recv", 309, 95, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)) $ipinp = GUICtrlCreateInput(@IPAddress1, 8, 24, 120, 21) GUICtrlCreateLabel("IP", 8, 8, 120, 15) $portinp = GUICtrlCreateInput("4324", 8, 64, 120, 21) GUICtrlCreateLabel("Port", 8, 48, 120, 15) $fileinp = GUICtrlCreateInput("", 136, 24, 136, 21) GUICtrlCreateLabel("File to Save to", 136, 8, 120, 15) $sendbut = GUICtrlCreateButton("&Recive", 136, 56, 166, 33, 0) $filechoosebut = GUICtrlCreateButton("..", 280, 24, 21, 21, 0) _StartRecv() Func _StartRecv() GUISwitch($rcvGui) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $sendbut _FileReceive(GUICtrlRead($fileinp), GUICtrlRead($ipinp), GUICtrlRead($portinp)) ExitLoop Case $filechoosebut $fod = FileSaveDialog("","","All (*.*)",16) If @error Then ContinueLoop If Not FileExists(StringLeft($fod,StringInStr($fod,"\",0,-1)-1)) Then DirCreate(StringLeft($fod,StringInStr($fod,"\",0,-1)-1)) GUICtrlSetData($fileinp,$fod) EndSwitch WEnd GUISetState(@SW_HIDE) EndFunc ;==>_StartSend ;=============================================================================== ; ; Function Name: _FileReceive ; Description:: Receives a File from an Client (See _FileSend) ; Parameter(s): ;$sFileName [Optional] : The Filename to save (if default or "" then using the original File Name) ;$IP [Optional] : The IP where the Server run, Default = @IPAdress1 ;$PORT [Optional] : The Port to use (must be the same as by _FileSend!!) ;$iSplash [Optional] : 1(defaul) = show SplashText ; Requirement(s): - ; Return Value(s): On Succes Return 1 ; On faild Return -1 and @error code 1-3: ; @error = 1: Error creating Listening socket on IP ; @error = 2: Faild to open file ; @error = 3: Faild to write file ; Author(s): GtaSpider ; ;=============================================================================== Func _FileReceive($sFileName = '', $IP = @IPAddress1, $PORT = 4324,$iSplash=1) Local $iMainSocket, $iAccSocket = -1, $sBuff, $sRecv = "", $i = 0, $iFirstWhile = True TCPStartup() $iMainSocket = TCPListen($IP, $PORT) If @error Then Return SetError(1,0,-1) If $iSplash Then $iSplash = SplashTextOn('','Wait For Incoming...',200,20,-1,-1,1) While $iAccSocket = -1 $iAccSocket = TCPAccept($iMainSocket) Sleep(50) WEnd $sBuff = Binary ($sBuff) If $iSplash Then ControlSetText($iSplash,'','Static1','Incoming...') While $sRecv = "" $sRecv = TCPRecv($iAccSocket, 2048, 1) $sRecv = BinaryToString ($sRecv) WEnd If $iSplash Then ControlSetText($iSplash,'','Static1','Receive File...') While $sRecv <> "" If StringInStr($sRecv, ',') And $iFirstWhile Then $sTmp = StringLeft($sRecv, StringInStr($sRecv, ",") - 1) $sRecv = StringTrimLeft($sRecv, StringLen($sTmp) + 1) If StringLen($sFileName) < 1 Then $sFileName = $sTmp $iFirstWhile = False EndIf $sBuff &= $sRecv $sRecv = BinaryToString (TCPRecv($iAccSocket, 2048, 1)) If @error Then ExitLoop WEnd If $iSplash Then ControlSetText($iSplash,'','Static1','Write To File...') If FileExists($sFileName) Then $sTmp = StringSplit($sFileName, ".") If $sTmp[0] < 2 Then While 1 $i += 1 If Not FileExists($sFileName & "(" & $i & ")") Then $sFileName = $sFileName & "(" & $i & ")" ExitLoop EndIf WEnd Else While 1 $i += 1 If Not FileExists($sTmp[1] & "(" & $i & ")" & $sTmp[2]) Then $sFileName = $sTmp[1] & "(" & $i & ")." & $sTmp[2] ExitLoop EndIf WEnd EndIf EndIf $iFileOp = FileOpen($sFileName, 16 + 2) If @error Then Return SetError(2,0,-1) FileWrite($iFileOp, $sBuff) If @error Then Return SetError(3,0,-1) FileClose($iFileOp) If $iSplash Then ControlSetText($iSplash,'','Static1','Succesfull!') TCPCloseSocket($iAccSocket) TCPShutdown() Sleep(1000) Return 1 EndFunc ;==>_FileReceiveoÝ÷ Ù°¥éíý¶®¶sb6æ6ÇVFRfÇC´uT6öç7FçG2æS2fwC° ¢b33c·6æDwVÒuT7&VFRgV÷C´6ÆVçBÒ6VæBgV÷C²Â3ÂRÂÓÂÓÂÓÂ&Dõ"b33cµu5ôUõDôôÅtäDõrÂb33cµu5ôUõDõÔõ5BÂb33cµu5ôUõtäDõtTDtR¢b33c¶çÒuT7G&Ä7&VFTçWBFG&W73ÂÂ#BÂ#Â#¤uT7G&Ä7&VFTÆ&VÂgV÷C´gV÷C²ÂÂÂ#ÂR¢b33c·÷'FçÒuT7G&Ä7&VFTçWBgV÷C³C3#BgV÷C²ÂÂcBÂ#Â#¤uT7G&Ä7&VFTÆ&VÂgV÷Cµ÷'BgV÷C²ÂÂCÂ#ÂR¢b33c¶fÆVçÒuT7G&Ä7&VFTçWBgV÷C²gV÷C²Â3bÂ#BÂ3bÂ#¤uT7G&Ä7&VFTÆ&VÂgV÷C´fÆRgV÷C²Â3bÂÂ#ÂR¢b33c·6VæF'WBÒuT7G&Ä7&VFT'WGFöâgV÷C²f×µ6VæBgV÷C²Â3bÂSbÂcbÂ32¢b33c¶fÆV6ö÷6V'WBÒuT7G&Ä7&VFT'WGFöâgV÷C²ââgV÷C²Â#Â#BÂ#Â# ¥õ7F'E6VæB ¤gVæ2õ7F'E6VæB uT7vF6b33c·6æDwV uT6WE7FFR vÆR b33c¶ä×6rÒuTvWD×6r 7vF6b33c¶ä×6p 66Rb33c´uTôUdTåEô4Äõ4P WDÆö÷ 66Rb33c·6VæF'W@ ôfÆU6VæBuT7G&Å&VBb33c¶fÆVçÂuT7G&Å&VBb33c¶çÂuT7G&Å&VBb33c·÷'Fç WDÆö÷ 66Rb33c¶fÆV6ö÷6V'W@ b33c¶föBÒfÆT÷VäFÆörgV÷C²gV÷C²ÂgV÷C²gV÷C²ÂgV÷C´Æ¢â¢gV÷C²Ã2 bW'&÷"FVâ6öçFçVTÆö÷ uT7G&Å6WDFFb33c¶fÆVçÂb33c¶föB VæE7vF6 tVæ@ uT6WE7FFR5uôDR¤VæDgVæ2³ÓÒfwCµõ7F'E6Væ@ £³ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓУ°£²gVæ7FöâæÖS¢ôfÆU6Væ@£²FW67&Fö㣢6VæFærfÆRFòâ6W'fW"6VRôfÆU&V6VfR£²&ÖWFW"2 £²b33c·4fÆR¢FRfÆRFò6Væ@£²b33c´¢FRF&vWBG&W70£²b33cµõ%B´÷FöæÅÒ¢FR÷'BFòW6R×W7B&RFR6ÖR2'ôfÆU&V6WfRb333²b333²£²b33c¶7Æ6´÷FöæÅÒ¢FVfVÂÒ6÷r7Æ6FW@£²ÒFöçB6÷r7Æ6FW@£²b33c¶vEvÆT6öææV7FVB´÷FöæÅÒ¢ÒbD56öææV7BfÆBW'&÷"&WGW&âvFW'&÷"6öFR £²FVfVÇBÒbD56öææV7BfÆBWBBâvÆRVçFÂ6öææV7FV@£²&WV&VÖVçB2¢Ð£²&WGW&âfÇVR2¢öâ7V66W2&WGW&⣲öâfÆB&WGW&âÓæBW'&÷"6öFRÓ3 £²W'&÷"Ò¢fÆRæ÷BW7@£²W'&÷"Ò#¢D56öææV7BfÆBöæÇ&ÆRbb33c¶vEvÆT6öææV7FVBfÇC²fwC²£²W'&÷"Ò3¢fÆBFò÷VâfÆP£²W'&÷"ÒC¢6öææV7Föç&ö&ÆVÒvÆR6VæFæp£²WF÷"2¢wF7FW £°£³ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÐ ¤gVæ2ôfÆU6VæBb33c·4fÆRÂb33c´Âb33cµõ%BÒC3#BÂb33c¶7Æ6ÒÂb33c¶vEvÆT6öææV7FVBÒ Æö6Âb33c¶Öå6ö6¶WBÒÓÂb33c·4'VfbÂb33c¶fÆT÷Âb33c·5&V7` bæ÷BfÆTW7G2b33c·4fÆRFVâ&WGW&â6WDW'&÷"ÂÂÓ bb33c¶7Æ6FVâb33c¶7Æ6Ò7Æ6FWDöâb33²b33²Âb33µG'Fò6öææV7Bâââb33²Â#Â#ÂÓÂÓ D57F'GW bçVÖ&W"b33c¶vEvÆT6öææV7FVBÒFVà vÆRb33c¶Öå6ö6¶WBÒÓ b33c¶Öå6ö6¶WBÒD56öææV7Bb33c´Âb33cµõ%B tVæ@ VÇ6P b33c¶Öå6ö6¶WBÒD56öææV7Bb33c´Âb33cµõ%B bW'&÷"FVâ&WGW&â6WDW'&÷""ÂÂÓ VæD` bb33c¶7Æ6FVâ6öçG&öÅ6WEFWBb33c¶7Æ6Âb33²b33²Âb33µ7FF3b33²Âb33µ&VBfÆRâââb33² b33c¶fÆT÷ÒfÆT÷Vâb33c·4fÆRÂb bW'&÷"FVâ&WGW&â6WDW'&÷"2ÂÂÓ b33c·4'VfbÒ&æ'7G&æuG&ÔÆVgBb33c·4fÆRÂ7G&ætå7G"b33c·4fÆRÂgV÷C²b3#²gV÷C²ÂÓÂÓfײgV÷C²ÂgV÷C²fײfÆU&VBb33c¶fÆT÷ fÆT6Æ÷6Rb33c¶fÆT÷ bb33c¶7Æ6FVâ6öçG&öÅ6WEFWBb33c¶7Æ6Âb33²b33²Âb33µ7FF3b33²Âb33µ6VæFærfÆRâââb33² vÆR&æ'ÆVâb33c·4'Vfb b33c¶6VæE&WGW&âÒD56VæBb33c¶Öå6ö6¶WBÂb33c·4'Vfb bW'&÷"FVâ&WGW&â6WDW'&÷"BÂÂÓ G&Fb33²b33²Âb33c¶6VæE&WGW&â b33c·4'VfbÒ&æ'ÖBb33c·4'VfbÂb33c¶6VæE&WGW&â²Â&æ'ÆVâb33c·4'VfbÒb33c¶6VæE&WGW&â tVæ@ bb33c¶7Æ6FVâ6öçG&öÅ6WEFWBb33c¶7Æ6Âb33²b33²Âb33µ7FF3b33²Âb33µ7V66W6gVÆÂb333²b33² D56Æ÷6U6ö6¶WBb33c¶Öå6ö6¶WB D56WFF÷vâ 6ÆVW 7Æ6öfb &WGW&â¤VæDgVæ2³ÓÒfwCµôfÆU6VæMfg / Best Regarsd Spider www.AutoIt.de - Moderator of the German AutoIt Forum
emoyasha Posted January 19, 2008 Posted January 19, 2008 thanks much. i am starting to learn c++ and have realised the two launguges are very similar... Spoiler Admin Of:http://notmyspace.info [Under Development, looking for volunteers to help improve]http://PSNetCards.co.ukhttp://ZacnAndLindsey.com [Under development, not quite sure what to do with it yet]http://revelm.com------------------------------------Radio Streams:http://75.185.53.88:8000 [128kb/s 44kHz]http://75.185.53.88:8002 [22kb/s 22kHz](works on mobile phones)-----------------------------------My Server:Owned By: http://jumpline.comIP:66.84.19.220Bandwidth:200GBStorage Space:1TBNetwork Connection: 1GB/S[up and down]Operating System: Red Hat LinuxInstalled Apps:Webmail, phpBB, Majordomo, phpMyAdmin, MySQL, Active Server Pages, FrontPage Extensions 2002, GraphicsMagick, Mod Perl, Perl, PHP: Hypertext Preprocessor, Python(want cheap good webhosting, or need a place to park your domain? contact me)-----------------------------------
willyfoo Posted February 24, 2008 Posted February 24, 2008 Is it easy to write a simple FTP server just to take in a username,password and start accepting a file?
BrettF Posted February 24, 2008 Posted February 24, 2008 Is it easy to write a simple FTP server just to take in a username,password and start accepting a file?FTP.au3. Search for it. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Xwolf Posted April 23, 2008 Posted April 23, 2008 It's great useful for me. Thanks very much. But i get a problem when i transfered a pic. The process of transferring is successful but the data is destroy. Because i can't see anything when opening the pic. Wait for your help. Thanks again.
Andreik Posted April 24, 2008 Posted April 24, 2008 (edited) Your UDF is very useful but I want to send files from server to client. How would I do this Edited April 24, 2008 by Andreik
Kip Posted April 24, 2008 Posted April 24, 2008 I edited it to a real udf script, removed a lot of code, and the functions work in client And server: Recieve: expandcollapse popup; _FileRecieve($sFileName, $iAccSocket) ; ; $sFileName = Path to the new file ; $iAccSocket = Socket (from TCPConnect or TCPAccept) Func _FileReceive($sFileName, $iAccSocket) Local $sBuff, $sRecv = "", $i = 0, $iFirstWhile = True If @error Then Return 0 $sBuff = Binary ($sBuff) While $sRecv = "" $sRecv = TCPRecv($iAccSocket, 2048, 1) $sRecv = BinaryToString ($sRecv) WEnd While $sRecv <> "" If StringInStr($sRecv, ',') And $iFirstWhile Then $sTmp = StringLeft($sRecv, StringInStr($sRecv, ",") - 1) $sRecv = StringTrimLeft($sRecv, StringLen($sTmp) + 1) If StringLen($sFileName) < 1 Then $sFileName = $sTmp $iFirstWhile = False EndIf $sBuff &= $sRecv $sRecv = BinaryToString (TCPRecv($iAccSocket, 2048, 1)) If @error Then ExitLoop WEnd $iFileOp = FileOpen($sFileName, 16 + 2) If @error Then Return 0 FileWrite($iFileOp, $sBuff) If @error Then Return 0 FileClose($iFileOp) Return 1 EndFunc ;==>_FileReceive Send: ; _FileSend($sFile, $iMainSocket) ; ; $sFile = Path to the file to send ; $iMainSocket = Socket (from TCPConnect or TCPAccept) Func _FileSend($sFile, $iMainSocket) Local $sBuff, $iFileOp,$sRecv $iFileOp = FileOpen($sFile, 16) If @error Then Return 0 $sBuff = Binary(StringTrimLeft($sFile,StringInStr($sFile,"\",-1,-1))&",")&FileRead($iFileOp) FileClose($iFileOp) While BinaryLen($sBuff) $iSendReturn = TCPSend($iMainSocket, $sBuff) If @error Then Return 0 $sBuff = BinaryMid ($sBuff, $iSendReturn + 1, BinaryLen ($sBuff) - $iSendReturn) WEnd Return 1 EndFunc MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
Andreik Posted April 24, 2008 Posted April 24, 2008 (edited) Thx man. Nice work! Edited April 24, 2008 by Andreik
CHronologist Posted May 6, 2008 Posted May 6, 2008 (edited) it seems like i can't trasmitt files greater than 5kB. Any experience or explanation or solutions? thanks Edited May 6, 2008 by CHronologist
AcidCorps Posted October 5, 2008 Posted October 5, 2008 First I would like to say thank you for this but I'm having some issues I transferred a file (regedit as an example) and when transferring over local LAN it worked perfect however when I transferred over the internet (all ports open) the server detected and received the file but it was less then half the correct size and obviously not working, any clue what I may have done wrong?
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