• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Send a file across the network

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 213
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could send it using FTP.
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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/
 
dushantha Rathnayake
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Richard Golebiowski
Ranch Hand
Posts: 213
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic