摘要: 客户端代码: public class ClientDemo { public static void main(String[] args) throws IOException { //创建客户端的Socket对象 Socket s = new Socket("192.168.50.76",12 阅读全文
posted @ 2020-05-07 21:05 硬盘红了 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 发送端代码: /* UDP发送数据:数据来自于键盘录入,如果输入的数据是886,发送数据结束 */ public class SendDemo { public static void main(String[] args) throws IOException { //1.创建发送端对象 Data 阅读全文
posted @ 2020-05-07 19:36 硬盘红了 阅读(199) 评论(0) 推荐(0) 编辑
摘要: public class ReceivedDemo { public static void main(String[] args) throws IOException { //1.创建接收端Socket对象 DatagramSocket ds = new DatagramSocket(10086 阅读全文
posted @ 2020-05-07 18:56 硬盘红了 阅读(167) 评论(0) 推荐(0) 编辑
摘要: public class SendDemo { public static void main(String[] args) throws IOException { //1.创建发送端Socket对象 // DatagramSocket()构造数据报套接字并将其绑定到本地主机上的任何可用端口。 D 阅读全文
posted @ 2020-05-07 14:37 硬盘红了 阅读(317) 评论(0) 推荐(0) 编辑