📄 daybcast.txt
字号:
import java.net.*;
import java.util.*;
public class DayBcast
{
private DatagramSocket ds;
private DatagramPacket dp;
private InetAddress addr;
public static void main(String[] args) throws Exception
{
DayBcast db = new DayBcast("localhost");
db.go();
}
public DayBcast(String target) throws Exception
{
addr = ...;//将target转换为InetAddress对象
ds = ...;//新建的数据报套接字
}
public void go() throws Exception
{
byte[] buff;
...//循环
{
Thread.sleep(1000);//1s间隔
System.out.println("Sending...");
...//取得服务器系统当前时间
buff =...;//将系统时间转换为字节型数组
dp =...;//构造发送数据报
...;//发送dp
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -