Forums Register Login

Send a file across the network

+Pie Number of slices to send: Send
Hi,

I have an client server application. in some cases I want to send files between server and client. But I don't know how to do it. Can I do it using socket programming? the files that I want to send can be documents, media files, text files, pdf files, ect.... . Actually I want to send a file across the network. please help me.

thank you.
+Pie Number of slices to send: Send
You could send it using FTP.
+Pie Number of slices to send: Send
Sockets would work, and might be the fastest way to getting this implemented if the requirements are simple. Or you could use an embedded Java FTP server like http://mina.apache.org/ftpserver/ and a client like http://commons.apache.org/net/
+Pie Number of slices to send: Send
Hi,

My application is not a web application. I need to implement this file sending on a LAN. If I can use socket programming to do this, then how can I do it? If you have an example code please post it or if you can give me a link please post them. I am new for this socket programming side. Please help me.

Thank you.
+Pie Number of slices to send: Send
Searching for "java socket tutorial" should find the relevant chapter of the Sun Java Tutorial. It contains an example of a pair of standalone client/server applications that communicate via sockets.
+Pie Number of slices to send: Send
 

dushantha Rathnayake wrote:Hi,

My application is not a web application. I need to implement this file sending on a LAN. If I can use socket programming to do this, then how can I do it? If you have an example code please post it or if you can give me a link please post them. I am new for this socket programming side. Please help me.

Thank you.



It doesn't matter if it's a web application. As long as the network is TCP, you can use a FTP server and client as was suggested. For a project, I wrote a DOS FTP server in Java and a DOS client in Pascal that was used to replace file transfer vis modem in an application. The client was not a web application.
+Pie Number of slices to send: Send
Hi!

Below is a very basic sample of using sockets for transfering files of any type over the network, but it could give you general idea. Output file is written to current server working directory and no additional checking is provided. So if file of the same name already exists, it would be overwritten.

Server.java


and Client.java
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 15476 times.
Similar Threads
Writing a file across a network
A question about BufferedImage class.
Socket Accept
DETECT if a CLIENT still exits
copying files over the internet with sockets
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:24:35.