• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

am copying file using java api . which port i should open?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. if both source and destination are using windows platforms.
2. pls tell me which port i should open.
3. pls tell me TCP is enough or not.
 
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since it looks like file transfer, you can create your own protocol or use an existing one. If you create your own, you can use whatever port you want. A port is just a number, an ID. Be aware if you are running another server that uses a certain port there may be conflicts. Unless you are implementing a service that uses a well known port(<1024) avoid those, as well as the ones in the 1024 to 8000ish range. Those are often used by OS services and other commercial applications. To be safe, use >20000 if you aare implementing your own transfer protocol.

On the client side, you can just let the OS(maybe the JVM with java, not sure. Most of my network programming is done in C) the port that it binds to. You rarely need to explicitly use a port client side. On the server side, it is almost always necessary of course.

Implementing an exisitng protocol could prove to be easier and more beneficial. The two major file transfer protocols are FTP and SFTP(Simple File Transfer Protocol). Implementation details(including transmission protocols and ports) can be found here:


http://www.faqs.org/rfcs/rfc959.html

http://www.faqs.org/rfcs/rfc913.html

RFC is very neat to peruse. Every standard protocol you can think of is there in its gory details: http, mail protocols, mime, ect.

A big benefit is that if you implement FTP or SFTP properly, any client that knows the protocol can connect to your server, and your client can connect to any server that implements them as well.

TCP is both used in FTP and SFTP and suitable for any type of file transer you want. UDP would be bad, since you don't want to lose packets in a file transfer.

It doesn't and should never matter what the underlying OS is, on both client and server, for most internet tasks. In fact, the internet is platform independant. What matters are hardware level issues, like endian, but Java pretty much deals with it for you. Of course, what networking API that you use is important to your platform(windows, *nix, Java, ect), but that should be transparent to the client. All the client needs to know is how to send data and how to read data sent from the server. Same for the server.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic