I follow the UDP tutorials at http://docs.oracle.com/javase/tutorial/networking/datagrams/broadcasting.html , I copied all the code and compiled it, now if I compile the client first and then the server, the server will print it's on the console
Exception in thread "main" java.net.BindException: Address already in use: Cannot bind at java.net.PlainDatagramSocketImpl.bind0(Native Method) at java.net.PlainDatagramSocketImpl.bind(Unknown Source) at java.net.DatagramSocket.bind(Unknown Source) at java.net.DatagramSocket.<init>(Unknown Source) at java.net.DatagramSocket.<init>(Unknown Source) at java.net.DatagramSocket.<init>(Unknown Source) at QuoteServerThread.<init>(QuoteServerThread.java:19) at MulticastServerThread.<init>(MulticastServerThread.java:10) at MulticastServer.main(MulticastServer.java:3)
QuoteServerThread line 19
socket = new DatagramSocket(12345);
Line 10 MulticastServerThread
public MulticastServerThread() throws IOException { super("MulticastServerThread");
MulticastServer 3 String -
public class MulticastServer { public static void main(String[] args) throws java.io.IOException { new MulticastServerThread().start();
If I first started the server and then the client, the client prints it to the console
Exception in thread "main" java.net.BindException: Address already in use: Cannot bind at java.net.PlainDatagramSocketImpl.bind0(Native Method) at java.net.PlainDatagramSocketImpl.bind(Unknown Source) at java.net.DatagramSocket.bind(Unknown Source) at java.net.MulticastSocket.<init>(Unknown Source) at java.net.MulticastSocket.<init>(Unknown Source) at MulticastClient.main(MulticastClient.java:9)
Line 9 multicast
MulticastSocket socket = new MulticastSocket(12345);
Looking at the errors, it seems to me that this is due to listening on ports, how can I fix this?
Canvas
source share