Simple connection example part II - TCP communication

SDK Version: 
Last time I wrote about UDP connection. I got some comments about the problem, that UDP packets are not guaranteed to be delivered.
This time I’m going to show you the safer option, the TCP connection.
TCP is probably the most commonly used protocol, simply because it is used for so many applications such as HTTP, POP, SMTP, etc. TCP is a protocol which guarantees that the receiver will receive exactly what the sender sent - there will be no errors, it will be in the correct order, everything will work just fine.

TCP communication time diagram.

  1. try {
  2.         Socket s = new Socket("",80);
  3. } catch (UnknownHostException e) {
  4.         // TODO Auto-generated catch block
  5.         e.printStackTrace();
  6. } catch (IOException e) {

Syndicate content