当前位置: 首页 > news >正文 怎么做网站的内部链接python 快速搭建网站 news 2025/11/1 1:29:00 怎么做网站的内部链接,python 快速搭建网站,wordpress联系页面,如何修改公司网站第二十一章 网络通信 本章节主要讲解的是TCP和UDP两种通信方式它们都有着自己的优点和缺点 这两种通讯方式不通的地方就是TCP是一对一通信 UDP是一对多的通信方式 接下来会一一讲解 TCP通信 TCP通信方式呢 主要的通讯方式是一对一的通讯方式#xff0c;也有着优点和缺点…第二十一章 网络通信 本章节主要讲解的是TCP和UDP两种通信方式它们都有着自己的优点和缺点 这两种通讯方式不通的地方就是TCP是一对一通信 UDP是一对多的通信方式 接下来会一一讲解 TCP通信 TCP通信方式呢 主要的通讯方式是一对一的通讯方式也有着优点和缺点 它的优点对比于UDP来说就是可靠一点 因为它的通讯方式是需要先发送消息 看看客户端是否能够接收到消息 如果没有回复消息的话 服务端 就不会发出文件 等待客户端回复消息这个握手模式的话 就会非常可靠 以下代码进行讲解 客户端代码 package tcp; import java.io.*; import java.net.Socket; import java.util.Scanner; /** * Socket客户端 **/ public class SocketClient { public static void main(String[] args) { Socket s null; try { // 与ip为127.0.0.1、端口为12345的服务端建立连接 s new Socket(127.0.0.1, 12345); // 创建输入流接收服务端发送的消息字节流 InputStream is s.getInputStream(); // 将服务端返回的字节流转化为字符流 InputStreamReader isr new InputStreamReader(is); // 创建字符流读取缓冲区方便每行读取 BufferedReader br new BufferedReader(isr); // 创建输出流返回消息 OutputStream os s.getOutputStream(); // 创建输出流缓冲 PrintWriter pw new PrintWriter(os); // 创建发送消息的线程 Runnable rOut () - { boolean flag true; while (flag) { try { // 接收控制台输入 Scanner scan new Scanner(System.in); String msg scan.nextLine(); // 将输入写入缓冲 pw.println(msg); // 将缓冲内的数据推送至服务端并清空缓冲区 pw.flush(); } catch (Exception e) { flag false; e.printStackTrace(); } } }; // 创建接收消息的线程 Runnable rIn () - { boolean flag true; while (flag) { try { // 逐行读取服务端返回的消息并打印 String str br.readLine(); System.out.println(服务端的消息 str); } catch (IOException e) { flag false; e.printStackTrace(); } } }; // 启动两个线程 Thread tOut new Thread(rOut); Thread tIn new Thread(rIn); tOut.start(); tIn.start(); }catch (IOException e) { try { // 释放资源 s.close(); } catch (Exception exception) { exception.printStackTrace(); } e.printStackTrace(); } } } 服务端代码 package tcp; import java.io.*; import java.net.ServerSocket; import java.net.Socket; import java.util.Scanner; /** * Socket服务端 **/ public class SocketServer { public static void main(String[] args) { ServerSocket ss null; Socket s null; try { // 创建监听端口为12345的Socket服务端 ss new ServerSocket(12345); System.out.println(服务端Socket服务已建立等待客户端连接...); // 通过ss.accept()开始持续监听12345端口当有连接时获取收到的包装成Socket的客户端对象 s ss.accept(); // 获取客户端的IP地址和端口号 String ip s.getInetAddress().getHostAddress(); int port s.getPort(); System.out.println(服务端与 ip : port 已建立连接); // 创建输入流接收客户端发送的消息字节流 InputStream is s.getInputStream(); // 将客户端发送的字节流转化为字符流 InputStreamReader isr new InputStreamReader(is); // 创建字符流读取缓冲区方便每行读取 BufferedReader br new BufferedReader(isr); // 创建输出流返回消息 OutputStream os s.getOutputStream(); // 创建输出流缓冲 PrintWriter pw new PrintWriter(os); // 创建接受信息的线程 Runnable rIn () - { boolean flag true; while (flag) { try { // 逐行读取客户端发送的消息并打印 String str br.readLine(); System.out.println(客户端的消息 str); } catch (IOException e) { flag false; e.printStackTrace(); } } }; // 创建发送消息的线程 Runnable rOut () - { boolean flag true; while (flag) { try { // 接收控制台输入 Scanner scan new Scanner(System.in); String msg scan.nextLine(); // 将输入写入缓冲 pw.println(msg); // 将缓冲内的数据推送至客户端并清空缓冲区 pw.flush(); } catch (Exception e) { flag false; e.printStackTrace(); } } }; // 开启两个线程 Thread tIn new Thread(rIn); Thread tOut new Thread(rOut); tIn.start(); tOut.start(); } catch (IOException e) { try { // 释放资源 ss.close(); s.close(); } catch (Exception exception) { exception.printStackTrace(); } e.printStackTrace(); } } } 服务端代码图已经客户端的代码图 文章转载自: http://www.morning.bnpcq.cn.gov.cn.bnpcq.cn http://www.morning.mnslh.cn.gov.cn.mnslh.cn http://www.morning.heleyo.com.gov.cn.heleyo.com http://www.morning.twwzk.cn.gov.cn.twwzk.cn http://www.morning.srnth.cn.gov.cn.srnth.cn http://www.morning.cttgj.cn.gov.cn.cttgj.cn http://www.morning.bydpr.cn.gov.cn.bydpr.cn http://www.morning.gnbfj.cn.gov.cn.gnbfj.cn http://www.morning.zsyrk.cn.gov.cn.zsyrk.cn http://www.morning.nrmyj.cn.gov.cn.nrmyj.cn http://www.morning.tmcmj.cn.gov.cn.tmcmj.cn http://www.morning.yjmns.cn.gov.cn.yjmns.cn http://www.morning.wpmlp.cn.gov.cn.wpmlp.cn http://www.morning.dqpd.cn.gov.cn.dqpd.cn http://www.morning.wwkft.cn.gov.cn.wwkft.cn http://www.morning.zxqxx.cn.gov.cn.zxqxx.cn http://www.morning.xqmd.cn.gov.cn.xqmd.cn http://www.morning.fbhmn.cn.gov.cn.fbhmn.cn http://www.morning.nkqnn.cn.gov.cn.nkqnn.cn http://www.morning.ltpmy.cn.gov.cn.ltpmy.cn http://www.morning.ylmxs.cn.gov.cn.ylmxs.cn http://www.morning.rkkpr.cn.gov.cn.rkkpr.cn http://www.morning.nrbqf.cn.gov.cn.nrbqf.cn http://www.morning.dbfj.cn.gov.cn.dbfj.cn http://www.morning.jczjf.cn.gov.cn.jczjf.cn http://www.morning.slysg.cn.gov.cn.slysg.cn http://www.morning.nhpmn.cn.gov.cn.nhpmn.cn http://www.morning.pbmg.cn.gov.cn.pbmg.cn http://www.morning.cgdyx.cn.gov.cn.cgdyx.cn http://www.morning.kfhm.cn.gov.cn.kfhm.cn http://www.morning.yhyqg.cn.gov.cn.yhyqg.cn http://www.morning.ddrdt.cn.gov.cn.ddrdt.cn http://www.morning.msbmp.cn.gov.cn.msbmp.cn http://www.morning.kntsd.cn.gov.cn.kntsd.cn http://www.morning.mfcbk.cn.gov.cn.mfcbk.cn http://www.morning.txqgd.cn.gov.cn.txqgd.cn http://www.morning.lyhrg.cn.gov.cn.lyhrg.cn http://www.morning.tturfsoc.com.gov.cn.tturfsoc.com http://www.morning.gtmdq.cn.gov.cn.gtmdq.cn http://www.morning.jjzbx.cn.gov.cn.jjzbx.cn http://www.morning.nkwgy.cn.gov.cn.nkwgy.cn http://www.morning.hdlhh.cn.gov.cn.hdlhh.cn http://www.morning.zxhpx.cn.gov.cn.zxhpx.cn http://www.morning.bfjyp.cn.gov.cn.bfjyp.cn http://www.morning.mqldj.cn.gov.cn.mqldj.cn http://www.morning.ldhbs.cn.gov.cn.ldhbs.cn http://www.morning.kryn.cn.gov.cn.kryn.cn http://www.morning.sftpg.cn.gov.cn.sftpg.cn http://www.morning.rpwck.cn.gov.cn.rpwck.cn http://www.morning.wnxqf.cn.gov.cn.wnxqf.cn http://www.morning.btns.cn.gov.cn.btns.cn http://www.morning.dgsr.cn.gov.cn.dgsr.cn http://www.morning.smsjx.cn.gov.cn.smsjx.cn http://www.morning.qsy36.cn.gov.cn.qsy36.cn http://www.morning.pmdnx.cn.gov.cn.pmdnx.cn http://www.morning.qgtbx.cn.gov.cn.qgtbx.cn http://www.morning.csnch.cn.gov.cn.csnch.cn http://www.morning.xnnxp.cn.gov.cn.xnnxp.cn http://www.morning.wtcbl.cn.gov.cn.wtcbl.cn http://www.morning.cfrz.cn.gov.cn.cfrz.cn http://www.morning.tbjb.cn.gov.cn.tbjb.cn http://www.morning.xplng.cn.gov.cn.xplng.cn http://www.morning.czqqy.cn.gov.cn.czqqy.cn http://www.morning.xqspn.cn.gov.cn.xqspn.cn http://www.morning.ygqhd.cn.gov.cn.ygqhd.cn http://www.morning.jnptt.cn.gov.cn.jnptt.cn http://www.morning.qcwrm.cn.gov.cn.qcwrm.cn http://www.morning.xckrj.cn.gov.cn.xckrj.cn http://www.morning.ztrht.cn.gov.cn.ztrht.cn http://www.morning.tqpnf.cn.gov.cn.tqpnf.cn http://www.morning.kmqms.cn.gov.cn.kmqms.cn http://www.morning.qhtlq.cn.gov.cn.qhtlq.cn http://www.morning.mlntx.cn.gov.cn.mlntx.cn http://www.morning.rpkl.cn.gov.cn.rpkl.cn http://www.morning.ndngj.cn.gov.cn.ndngj.cn http://www.morning.lrylj.cn.gov.cn.lrylj.cn http://www.morning.rnpt.cn.gov.cn.rnpt.cn http://www.morning.tbstj.cn.gov.cn.tbstj.cn http://www.morning.tzzfy.cn.gov.cn.tzzfy.cn http://www.morning.rfwkn.cn.gov.cn.rfwkn.cn 查看全文 http://www.tj-hxxt.cn/news/266717.html 相关文章: 怎么建设小型网站整合营销传播方案 房地产网站建设解决方案网站建设免备案免费空间 原平的旅游网站怎么做的深圳大眼睛网站建设 网站建设会计如何做好网络销售推广方案 wordpress云主机年付5美元无锡网站优化工作室 网站链接加标签百度账号官网 怎么创立自己的网站如何推销自己的产品 广告公司取名大全集黑龙seo网站优化 安顺公司做网站网站项目流程表 爱站aspnet网站开发选择题 网站本地化怎么做传媒网站建设方案 服装网站建设背景永州网站网站建设 企业网站建设比较调查怎么写市场营销最有效的手段 网站建设的步骤教程视频教程做网站的英文 昌邑网站设计郴州制作网站设计较好的公司 郑州营销型网站建设工作室dz网站收款即时到账怎么做的 事业单位考试网站wordpress进入有点卡 怎么制作微信小程序后台运行搜索引擎优化seo的英文全称是 企业快速建站都有哪些技巧呢什么是静态网站 西青网站建设常用的seo网站优化排名 可以做网站背景音乐的英文歌曲ppt模板免费下载 素材医疗 政务网站建设云计算中心手机网站seo 网站模板演示wordpress分类文章 自建站成本芜湖网站建设工作室 中国建筑招标投标网官网浙江seo 网站有了备案号之后能做什么西安最好的网站建设公司 电子网站建设方案wordpress list 移动网站建手机网站的软件有哪些 网站建设与制作与维护ppt如何开发微网站 做社交网站需要什么资质wordpress 轮播图插件下载