import java.io.IOException;
import java.net.*;
public class UDPServer {
public static final int LocalPort = 3000;
public static final int RemotePort = 9000;
public static void main(String[] args) {
// TODO Auto-generated method stub
String str_send = "I am Server!";
byte[] buf = new byte[1024];
DatagramSocket dp_recvSock = null;
InetAddress localAddress = null;
InetAddress remoteAddress = null;
//���������socket
try {
dp_recvSock = new DatagramSocket(LocalPort);
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
localAddress = InetAddress.getLocalHost();
} catch (UnknownHostException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
remoteAddress = localAddress;
//�������ջ
【代码积累】UDP server
最新推荐文章于 2023-10-17 10:40:29 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)