DatagramSocket disconnect - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for DatagramSocket disconnect method.

This code example shows how to use the following methods:close, connect, disconnect, setSoTimeout
			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(); 
		} 
	} 

6
CodeRank
This code example shows how to use the following methods:close, disconnect
      return true; 
   } 
 
   private boolean checkUdpPort(int port) {
      try { 
         DatagramSocket ds = new DatagramSocket(port, InetAddress.getLocalHost());
         ds.close();
         ds.disconnect();
      } catch (Exception e) {
         return false; 
      } 
      return true; 
   } 
} 
5
CodeRank
This code example shows how to use the following methods:close, disconnect, isConnected
	 */ 
	public void dispose() { 
		isRunning = false;
		_myThread = null;
		if (_myDatagramSocket != null) {
			if (_myDatagramSocket.isConnected()) {
				Logger.printDebug("UdpServer.dispose()", "disconnect()"); 
				_myDatagramSocket.disconnect();
			} 
			Logger.printDebug("UdpServer.dispose()", "close()"); 
			_myDatagramSocket.close();
			_myDatagramSocket = null;
			Logger.printDebug("UdpServer.dispose()", 
					"Closing unicast datagram socket."); 
		} 
	} 
 
	/** 
	 * send a byte array to a previously defined remoteAddress. 
	 *  
5
CodeRank
This code example shows how to use the following methods:disconnect, isClosed, isConnected
        socket.setSoTimeout(timeout);
    } 
 
    private void disconnect() { 
         
       if (null != socket && socket.isConnected()) { 
           socket.disconnect();
       } 
         
       if (null != socket && !socket.isClosed()) {
           socket.close();
       } 
         
    } 
 
    public int readDataBlock(byte[] buf) throws IOException {
        //send trigger data 
        socket.send(trigger_packet);
        //receive data 
        DatagramPacket packet = new DatagramPacket(buf, buf.length, drone_addr, data_port);
5
CodeRank
This code example shows how to use the following methods:close, disconnect, isConnected
This code example shows how to use the following methods:close, disconnect, isConnected
This code example shows how to use the following methods:close, disconnect, isConnected
This code example shows how to use the following methods:close, disconnect, isConnected
	 */ 
	public void close() { 
		try { 
 
			// 关闭接收套接字 
			if (receiveSocket.isConnected()) {
				receiveSocket.disconnect();
				receiveSocket.close();
			} 
 
			// 关闭发送套接字 
			if (sendSocket.isConnected()) {
				sendSocket.disconnect();
				sendSocket.close();
			} 
		} catch (Exception ex) {
			ex.printStackTrace();
		} 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:close, disconnect
	} 
 
	@Override 
	protected void onPostExecute(Void args) {
		this._rSocket.close();
		this._sSocket.close();
		this._sSocket.disconnect();
		finalize(); 
	} 
	 
	@Override 
	protected void finalize() { 
		final String hostName = DefuzeMe.Preferences.get(string.hostName);
 
		DefuzeMe.Gui.hideProgress(); 
		 
		if (Clients.Hosts.size() <= 0) 
			DefuzeMe.Network.onNetworkComplete(Settings._BCastNoClient); 
		else if (Clients.Hosts.containsKey(hostName) == false)
			DefuzeMe.Network.onNetworkComplete(Settings._SelectClient); 
5
CodeRank
This code example shows how to use the following methods:close, disconnect
this.running = false;
 
		if (this.socket != null)
		{ 
			this.socket.disconnect ( );
			this.socket.close ( );
		} 
	} 
} 
5
CodeRank
disconnect Method Overview
Disconnects this UDP datagram socket from the remote host.
See Code Examples for other Java 8 DatagramSocket Methods: