DatagramSocket isClosed - 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 isClosed method.

This code example shows how to use the following methods:isClosed, receive, setSoTimeout
  } 
 
  public RtpPacket receive() throws IOException { 
    try { 
      DatagramPacket dataPack = new DatagramPacket(buf, buf.length);
      socket.setSoTimeout(1);
      socket.receive(dataPack);
      RtpPacket inPacket = new RtpPacket(dataPack.getData(), dataPack.getLength());
      return inPacket;
    } catch( SocketTimeoutException e ) {
      //Do Nothing. 
    } catch (IOException e) {
      if (!socket.isClosed()) {
        throw new IOException(e);
      } 
    } 
    return null; 
  } 
 
  public void close() { 
8
CodeRank
This code example shows how to use the following methods:close, isClosed
	// =========================================================== 
	// Methods 
	// =========================================================== 
 
	public static final void closeSocket(final DatagramSocket pDatagramSocket) {
		if(pDatagramSocket != null && !pDatagramSocket.isClosed()) {
			pDatagramSocket.close();
		} 
	} 
 
	public static final void closeSocket(final Socket pSocket) {
		if(pSocket != null && !pSocket.isClosed()) {
			try { 
				pSocket.close();
			} catch (final IOException e) {
				Debug.e(e);
			} 
		} 
	} 
 
8
CodeRank
This code example shows how to use the following methods:isClosed, getNetworkInterface, joinGroup, setNetworkInterface, setTimeToLive
                if (mcSocket == null) {
                    mcSocket = new MulticastSocket(port);
                } 
 
                if (networkInterface != null) {
                    mcSocket.setNetworkInterface(networkInterface);
                } 
 
                mcSocket.joinGroup(address);
                mcSocket.setTimeToLive(64);
 
                if (!Tools.isAndroid()) { // Crashes in Android 2.3.3 emulator 
                    LOG.log(Level.FINE, "Connected to " + mcSocket.getNetworkInterface());
                } 
 
                connected = true;
            } 
        } 
 
        catch (final IOException e) {

6
CodeRank
This code example shows how to use the following methods:isClosed, getNetworkInterface, joinGroup, setNetworkInterface
                if (mcSocket == null) {
                    mcSocket = new MulticastSocket(port);
                } 
 
                if (networkInterface != null) {
                    mcSocket.setNetworkInterface(networkInterface);
                } 
 
                mcSocket.joinGroup(address);
 
                if (!Tools.isAndroid()) { // Crashes in Android 2.3.3 emulator 
                    LOG.log(Level.FINE, "Connected to " + mcSocket.getNetworkInterface());
                } 
 
                connected = true;
            } 
        } 
 
        catch (final IOException e) {
            LOG.log(Level.SEVERE, "Could not start receiver: " + e.toString(), e);

6
CodeRank
This code example shows how to use the following methods:close, isClosed
        } 
        else 
        { 
            boolean var3 = false;
 
            if (!par1DatagramSocket.isClosed())
            { 
                par1DatagramSocket.close();
                var3 = true;
            } 
 
            if (par2)
            { 
                this.socketList.remove(par1DatagramSocket);
            } 
 
            return var3;
        } 
    } 
 
5
CodeRank
This code example shows how to use the following methods:close, isClosed
      this.func_109837_a("closeSocket: " + var1);
      if(null == var1) {
         return false; 
      } else { 
         boolean var3 = false;
         if(!var1.isClosed()) {
            var1.close();
            var3 = true;
         } 
 
         if(var2) {
            this.field_109846_e.remove(var1);
         } 
 
         return var3;
      } 
   } 
 
   protected boolean func_109838_b(ServerSocket var1) {
      return this.func_109835_a(var1, true);
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, isClosed
        } 
        else 
        { 
            boolean var3 = false;
 
            if (!par1DatagramSocket.isClosed())
            { 
                par1DatagramSocket.close();
                var3 = true;
            } 
 
            if (par2)
            { 
                this.socketList.remove(par1DatagramSocket);
            } 
 
            return var3;
        } 
    } 
 
5
CodeRank
This code example shows how to use the following methods:close, isClosed
        } 
        else 
        { 
            boolean var3 = false;
 
            if (!par1DatagramSocket.isClosed())
            { 
                par1DatagramSocket.close();
                var3 = true;
            } 
 
            if (par2)
            { 
                this.socketList.remove(par1DatagramSocket);
            } 
 
            return var3;
        } 
    } 
 
5
CodeRank
This code example shows how to use the following methods:close, isClosed, isConnected
		public packetSender(DatagramPacket pack){
			this.packet=pack;
		} 
		public void run() { 
			try{ 
				if((socket==null)||(!socket.isConnected())||(socket.isClosed())){
					if((!(socket==null))&&(!(socket.isClosed())))
					{Log.d("closing", "socket");
					socket.close();}
					socket=null;
					socket=new DatagramSocket();//port binding not required as not listening here
				} 
				socket.send(packet);
				socket.close();
			} 
			 
			catch(SocketException e){
				Log.d("error","Socket conn error");
				e.printStackTrace();
			} catch (IOException e) {
5
CodeRank
isClosed Method Overview
Gets the state of this socket.
See Code Examples for other Java 8 DatagramSocket Methods: