Possible Duplicate:
how to implement TCP server and TCP client in java to transfer files
I write application which will send files to server through socket. Its very important to all files came correct from client to server with no errors, lost data and other like that. To do that I need to use TCP protocol I think but I dont know how to do that. Is socket in Java is default using TCP. If not how can I send data through TCP? Thanks for any help and tip.
There are two communication protocols that we can use for socket programming: User Datagram Protocol (UDP) and Transfer Control Protocol (TCP).
Here, two classes are being used: Socket and ServerSocket. The Socket class is used to communicate client and server. Through this class, we can read and write message. The ServerSocket class is used at server-side.
Definition: A socket is one endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent to. An endpoint is a combination of an IP address and a port number.
Java provides the reliable stream-based communication for TCP as well as the unreliable datagram communication for UDP.
Yes, you can use TCP for this and yes, Java sockets can do TCP.
If I were you, I'd start by following this tutorial: http://download.oracle.com/javase/tutorial/networking/sockets/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With