am copying file using java api . which port i should open?
Joined: Feb 20, 2006
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.
Joined: Jan 03, 2006
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:
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.
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra