main方法
package com.mysoft.socket;
import java.io.IOException;
import java.net.DatagramSocket;
import java.net.SocketException;
public class UdpChartDemo {
public static void main(String[] args) throws IOException {
DatagramSocket ss = new DatagramSocket();
DatagramSocket rs = new DatagramSocket(10000);
new Thread(new UdpSend2(ss)).start();
new Thread(new UdpRecv2(rs)).start();
}
}
报错信息:
Exception in thread "main" java.net.SocketException: Unrecognized Windows Sockets error: 0: Cannot bind
at java.net.PlainDatagramSocketImpl.bind0(Native Method)
at java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:82)
at java.net.DatagramSocket.bind(DatagramSocket.java:368)
at java.net.DatagramSocket.<init>(DatagramSocket.java:210)
at java.net.DatagramSocket.<init>(DatagramSocket.java:261)
at java.net.DatagramSocket.<init>(DatagramSocket.java:234)