Code example for DatagramSocket

Methods: close, connect, disconnect, setSoTimeout

0
			free(); 
		} 
 
		try 
		{ 
			socket = new DatagramSocket();
			socket.connect(new InetSocketAddress(ip, port));
			socket.setSoTimeout(timeOut);
			return true; 
		} 
		catch (Exception e)
		{ 
			errmsg = e.getMessage();
			return false; 
		} 
		finally 
		{ 
			free(); 
		} 
	} 
 
	@Override 
	public UsabilityDetail detectUsability() 
	{ 
		if(ok)
		{ 
			return UsabilityDetail.OK(); 
		} 
		else 
		{ 
			return UsabilityDetail.FAILURE(errmsg);
		} 
	} 
 
	@Override 
	public void free() 
	{ 
		if(socket!=null)
		{ 
			try 
			{ 
				socket.disconnect();
			} 
			catch(Exception e)
			{ 
				 
			} 
			try 
			{ 
				if(socket!=null)
				{ 
					socket.close();
				}				 
			} 
			catch(Exception e)
			{