⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 50be4b3b29e1001b18c7f243013b4a75

📁 简易聊天室,可能不很完善,请大家多提宝贵意见啊,本人纯属新手啊,请大家多多扶持
💻
字号:
package com.briup.test;
import java.io.IOException;
import java.net.*;

public class UdpSend {
  public static void main(String[] args) {
	   DatagramSocket ds = null;
	try {
		ds = new DatagramSocket();
	} catch (SocketException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	   String str="hello world";
	   DatagramPacket dp = null;
	try {
		dp = new DatagramPacket(str.getBytes(),str.length(),
				   InetAddress.getByName("127.0.0.1"),3000);
	} catch (UnknownHostException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	     try {
			ds.send(dp);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	     ds.close();
	     
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -