Sign in to follow this  
Followers 0
incepator

file transfer exemple

32 posts in this topic

hello

I searched the forum a good example with file transfer, using TCP functions.

I have not found anything that works well on any type of file .... exe,. rar,.jpg .. etc

Does anyone know a good example?

thanks !

Share this post


Link to post
Share on other sites



There is a FTP UDF that comes with AutoIt.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I would be interested in a script that uses TCPSend, not ftp.

thanks anyway.

Share this post


Link to post
Share on other sites

Do you want to write the client and server part?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Yes, I want a simple example ... server client that can send a file, I want to understand how it works ..

Share this post


Link to post
Share on other sites

The please have a look at TCPSend (client part) and TCPReceive (server part).

Replace InputBox with FileRead and you are done.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

try for a week .. but I fail probably wrong somewhere, or function is more complex than my knowledge

Part function:

$fisier = FileOpen ("C:\test.rar",4)
$continut_fisier=FileRead ( $fisier,FileGetSize("C:\test.rar"))
FileClose($fisier)
TCPSend($ConnectedSocket, $continut_fisier)
Edited by incepator

Share this post


Link to post
Share on other sites

I believe it will be easier for the users here to help you if you where to upload the work that you have done so far...


Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites

Have a look at the examples I pointed you to and you will see that your code isn't enough.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

One other thing, not related to TCPSend, but your code snippet.

When doing a FileRead, there's no reason to use FileGetSize with it. If you don't specify how much of the file to read, then it will read the whole thing, so all you're doing is slowing down the read process by using it.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Depending on the size of your file you have to send it in chunks. I think the max. packet size is 64k. Make sure to check the error codes returned by TCPSend.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

fail ... it's probably more complicated than it seems.

I'll keep trying though. thanks

Share this post


Link to post
Share on other sites

If you have problems post the code and we will see how we can help.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I managed to do, but the problem is that only send text files, other files can not send you any idea why?

probably because they use it:

$fisier = FileOpen("C:\exemple.rar",0)
$continut_fisier = FileRead($fisier)
FileClose($fisier)
TCPSend($Connected, $continut_fisier)
Edited by incepator

Share this post


Link to post
Share on other sites

Check the examples. They send the data as binary.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

If you're opening a file that is a binary file (.exe or .dll for example), you need to use fileopen with the binary flag of 16, and not 0.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

this is part of the script:

;1.

$fisier = FileOpen("C:\file.exe",16)
$continut_fisier = FileRead($fisier)
FileClose($fisier)
$sizw = FileGetSize("C:\file.exe")
$szData = "file.exe" & "<|*|>" & $continut_fisier & "<|*|>" & $sizw
TCPSend($Connected, $szData)

;2.

$comanda = StringSplit($recv, "<|*|>", 1)
$open2 = FileOpen("file.exe",1)
Do
$write = FileWrite($open2, $comanda[4])
Until FileGetSize("file.exe") = $comanda[5]
FileClose($open2)

the problem is only getting 15.6 kb...writing is not probably correct. :think:

Edited by incepator

Share this post


Link to post
Share on other sites

Wouldn't it be easier to do 3 TCP sends? 1) Filename 2) Filesize 3) file content

Your Do/Until loop doesn't make sense because you write the same data ($comanda[4]) again and again.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

I understand now,

not a continuous writing, just repeat the loop

think that if I use a separate reference for each time ... as you said you will work?

Thanks.

Edited by incepator

Share this post


Link to post
Share on other sites

As you can see writing a file transfer script can be quite time consuming. Why do you still want to write it yourself and not use FTP?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • AoRaToS
      By AoRaToS
      s!mpL3 LAN Messenger as the name suggests is a messenger designed and developed to offer chat communication over Local Area Networks while being as simple to use as possible. This project started way back in 2008 with only basic functionality and is regularly updated with new features in order to make it more useful and user friendly. What I wanted was a simple, small, serverless program that would work without installation cause that was the ideal combination for my workplace back then, so I ended up with this!

      I have attached some images from various versions:
      Check the rest below! (from various versions)

      Previous downloads: 7430 (Without counting the ones from the Downloads section.)

      Current version 2.9.8.8! [30/09/2015]  s!mpL3 LAN Messenger.zip
      [Attachment version updated to 2.9.8.8]  

      s!mpL3 LAN Messenger version 2.9.8.8 - [30/09/2015]

      1. Removed some test code that could cause message boxes to pop up for Windows versions prior to Windows 10.


      You can view/download the full change log here: ChangeLog.txt

      Tested and working on Windows XP, Windows Vista, Windows 7, Windows 8, Windows 8.1 and Windows 10.


      Things you need to know before trying it:

      1. Start the program, select one or more connections from what's available and click Connect (If a firewall notice comes up, click 'Allow' or 'Add Exception')
      When someone else on your network does the same, they will appear in your TreeView and you will appear in theirs, double click their name and chat!

      2. s!mpL3 LAN Messenger does not require a server to be running, it's standalone.

      3. On the first run an .ini file is created at @LocalAppDataDirs!mpL3 LAN Messenger which stores the settings so that they are used every time you run the application. If you delete the .ini file it will be created again (with default settings at program startup or with your selected settings if you press Save from the Preferences window).

      4. All communication is encrypted using AES so it's quite secure against Network sniffers.

      5. You can send files and folders by dragging and dropping them in a conversation window. Folders are compressed before being sent. You can also drop multiple items to be sent.

      6. There is a "Hide" button located in the tray right click context menu that will hide all open windows. You can assign a Hotkey combination from Preferences. The default combination is Ctrl+H.

      7. s!mpL3 LAN Messenger uses port 60000 by default. You can change the port used by adding "Port=****" (without quotes, stars represent numbers) to the Config file described above. Communication is UDP.

      8. There is an Updater feature you can use to always have the latest available version, you only need an internet connection for that to work. You might need to clear your Internet Explorer Temporary Files in order for it to find an updated version.

      9. You can Hide + Lock s!mpL3 LAN Messenger so it'll require a password in order to "Appear". To enable this, go to the Security Preferences.

      10. Note that versions after 2.9.8.1 are not compatible with previous versions due to the encryption used being changed. I recommend using the latest version, or at least use the same version over the LAN.


      Important Notice:

      I will not be releasing the source code, however, I might share some parts of code if requested...
      If you choose to decompile this software, don't release the source code.