Socket_TCP_UDP1
Socket programming is the key API for programming distributed applications on the Internet.
Compared : java.net supports two common network protocols (two way communication), TCP  and UDP
  • Connection
    • UDP :  is a connection-less, unreliable, datagram protocol
      • Applications  like DNS, NFS
    • TCP :  is a connection-oriented, reliable and stream based
  • Creating a Datagram and  Socket
    • UDP :
      DatagramSocket dps=null;
    • TCP
      Socket sockTCP = new Soceket();
  • Communication flow
    • UDP
      • Create Socket using socket
      • bind socket to an address
      • sending and receiving with recvform() and sendto()
    • TCP/IP
    • Client send receive by read() and write
    • Server send and receive by send() and receive
UDP Datagram :member objects

 
TCP : Socket member objects

 
A datagram : Client: coding example

a UDP socket Server :coding example

TCP local server : coding example

TCP Local Client:  coding example