public void close(){
  if (datagramSocket != null) {
    datagramSocket.close();
  }
}

public void close ( ) { if ( datagramSocket != null ) { datagramSocket . close ( ) ; } }
method to close the datagram socket
