SoFunction
Updated on 2025-03-09

Appears in Android: bind failed: EADDRINUSE Problem Solution

Appears in Android: bind failed: EADDRINUSE Problem Solution

Look at the following questions:

try{

DatagramSocket udpSocket = new DatagramSocket(DEFAULT_PORT );

} catch (Exception e)

{

();

}

//: bind failed: EADDRINUSE (Address already in use)



Solution:

Will:udpSocket = new DatagramSocket(DEFAULT_PORT );

Change to:

if(udpSocket==null){
udpSocket = new DatagramSocket(null);
(true);
(new InetSocketAddress(DEFAULT_PORT));
}

The problem was solved

Thank you for reading, I hope it can help you. Thank you for your support for this site!