当前位置: 首页 > news >正文

寿县移动公司网站建设免费制作详情页的网站

寿县移动公司网站建设,免费制作详情页的网站,东莞公司官网推广,进出口贸易公司注册需要什么条件TCP/IP网络编程:理解网络编程和套接字 网络编程又叫做套接字编程,是因为在网络编程中依赖使用套接字(socket),网络编程一般是C/S架构,即客户端/服务器模式,在服务器端依赖套接字绑定自身接口,并开启监听客户端连接&am…

TCP/IP网络编程:理解网络编程和套接字

网络编程又叫做套接字编程,是因为在网络编程中依赖使用套接字(socket),网络编程一般是C/S架构,即客户端/服务器模式,在服务器端依赖套接字绑定自身接口,并开启监听客户端连接,然后进行读写操作;客户端则依赖套接字进行接口连接,以进行收发操作。

服务器端

服务器端遵循以下步骤进行搭建

  1. 创建套接字
  2. 绑定监听端口
  3. 开始监听
  4. 接受连接
  5. 进行读写操作
  6. 关闭连接

下面是创建服务器端通讯的实例

//步骤1:创建套接字int server_sock;server_sock = socket(PF_INET,SOCK_STREAM,0);if (server_sock == -1){error_handing("socket() error");}//步骤2:绑定监听端口struct sockaddr_in server_addr;memset(&server_addr,0,sizeof(server_addr));server_addr.sin_family = AF_INET;server_addr.sin_addr.s_addr = htonl(INADDR_ANY);server_addr.sin_port = htons(atoi("3333"));if (bind(server_sock,(struct sockaddr *)&server_addr,sizeof(server_addr)) == -1){error_handing("bind() error");}//步骤3:开启监听if (listen(server_sock,5) == -1){error_handing("listen() error");}//步骤4:接受连接int accept_sock;struct sockaddr accept_addr;socklen_t len = sizeof(accept_addr);accept_sock = accept(server_sock,&accept_addr,&len);if (accept_sock == -1){error_handing("accept() error");}//步骤5:开始通讯char message[10];if (read(accept_sock,message,10) == -1){error_handing("read() error");}printf("Read message is %s\n",message);if (write(accept_sock,message,10) == -1){error_handing("write() error");}//步骤6:关闭连接close(accept_sock);close(server_sock);

客户端

客户端遵循以下步骤进行搭建

  1. 创建套接字
  2. 指定端口连接
  3. 进行通讯
  4. 关闭连接

下面是创建客户端通讯的实例

//步骤1:创建套接字int client_sock;client_sock = socket(PF_INET,SOCK_STREAM,0);if (client_sock == -1){error_handing("socket() error");}//步骤2:连接端口struct sockaddr_in connect_addr;connect_addr.sin_family = AF_INET;connect_addr.sin_addr.s_addr = inet_addr("127.0.0.1");connect_addr.sin_port = htons(3333);if (connect(client_sock,(struct sockaddr *)&connect_addr,sizeof(connect_addr)) == -1){error_handing("connect() error");}//步骤3:进行通讯if (write(client_sock,"nihao",sizeof("nihao")) == -1){error_handing("write() error");}char buffer[30];if (read(client_sock,buffer,30) ==  -1){error_handing("read() error");}printf("Receive message is %s\n",buffer);//步骤4:关闭连接close(client_sock);

网络套接字和文件描述符

在Linux环境中,操作网络套接字和文件描述符是一样的,上面实例中使用write()和read()函数操作网络套接字,
用法跟操作文件描述符别无二致,操作系统自动绑定了0、1、2对应I/O描述符的标准输入、标准输出和标准错误


文章转载自:
http://dinncochalklike.tpps.cn
http://dinncopip.tpps.cn
http://dinncomusicianly.tpps.cn
http://dinncohollowness.tpps.cn
http://dinncoinsurable.tpps.cn
http://dinncofluency.tpps.cn
http://dinncoectoblast.tpps.cn
http://dinncohumanics.tpps.cn
http://dinncothank.tpps.cn
http://dinncocurer.tpps.cn
http://dinncoviolent.tpps.cn
http://dinncoeyeshot.tpps.cn
http://dinncobelletrism.tpps.cn
http://dinncosiloxane.tpps.cn
http://dinncotrunk.tpps.cn
http://dinncolude.tpps.cn
http://dinncoapocalyptical.tpps.cn
http://dinncocuritiba.tpps.cn
http://dinncokohinoor.tpps.cn
http://dinncotransition.tpps.cn
http://dinncochinbone.tpps.cn
http://dinncoencroachment.tpps.cn
http://dinncobiramous.tpps.cn
http://dinncomullen.tpps.cn
http://dinncosandpaper.tpps.cn
http://dinncoredshank.tpps.cn
http://dinncosupertanker.tpps.cn
http://dinncopyrogravure.tpps.cn
http://dinncoorganist.tpps.cn
http://dinncodele.tpps.cn
http://dinncoweird.tpps.cn
http://dinncofacty.tpps.cn
http://dinncominicrystal.tpps.cn
http://dinncodescent.tpps.cn
http://dinncoecocatastrophe.tpps.cn
http://dinncotradesfolk.tpps.cn
http://dinncofacula.tpps.cn
http://dinncobeztine.tpps.cn
http://dinncokerulen.tpps.cn
http://dinncoceres.tpps.cn
http://dinncomeditative.tpps.cn
http://dinncotene.tpps.cn
http://dinncokinkcough.tpps.cn
http://dinncocollusive.tpps.cn
http://dinncocronyism.tpps.cn
http://dinncobrayer.tpps.cn
http://dinncohyperthermal.tpps.cn
http://dinncoflection.tpps.cn
http://dinncoradiocesium.tpps.cn
http://dinncoprecipitately.tpps.cn
http://dinncoundiversified.tpps.cn
http://dinncorussianize.tpps.cn
http://dinncooysterroot.tpps.cn
http://dinncodiplomapiece.tpps.cn
http://dinncosolder.tpps.cn
http://dinncothuswise.tpps.cn
http://dinncoemulative.tpps.cn
http://dinncotrinominal.tpps.cn
http://dinncotamale.tpps.cn
http://dinncoresonator.tpps.cn
http://dinncocalorific.tpps.cn
http://dinncochassis.tpps.cn
http://dinncomovietone.tpps.cn
http://dinncosightline.tpps.cn
http://dinncomonkeyish.tpps.cn
http://dinncocrooner.tpps.cn
http://dinncognawer.tpps.cn
http://dinncowoodland.tpps.cn
http://dinncoably.tpps.cn
http://dinncoresalute.tpps.cn
http://dinncoquarterstaff.tpps.cn
http://dinncoexpander.tpps.cn
http://dinncounlock.tpps.cn
http://dinncosavanna.tpps.cn
http://dinncomanning.tpps.cn
http://dinncolumber.tpps.cn
http://dinncoexarticulation.tpps.cn
http://dinncopinwheel.tpps.cn
http://dinncobad.tpps.cn
http://dinncoliechtensteiner.tpps.cn
http://dinncopreludious.tpps.cn
http://dinncohangchow.tpps.cn
http://dinncomusty.tpps.cn
http://dinncocontemptuous.tpps.cn
http://dinncofere.tpps.cn
http://dinncocrooner.tpps.cn
http://dinncocopperhead.tpps.cn
http://dinncotelepherique.tpps.cn
http://dinncosenility.tpps.cn
http://dinncolarrigan.tpps.cn
http://dinncoaugsburg.tpps.cn
http://dinncofixature.tpps.cn
http://dinncocoarseness.tpps.cn
http://dinncocalorigenic.tpps.cn
http://dinncoplutodemocracy.tpps.cn
http://dinncodisarming.tpps.cn
http://dinncoenamelling.tpps.cn
http://dinncoepidermoid.tpps.cn
http://dinncosolidarity.tpps.cn
http://dinncosputa.tpps.cn
http://www.dinnco.com/news/135009.html

相关文章:

  • 影视网站怎么做app杭州小周seo
  • 北京建设委员会网站首都之窗百度访问量统计
  • 如何免费做网站自己建网站怎样建
  • 网站左侧图片悬浮代码网站网络推广企业
  • 高端网页制作公司哪家好深圳seo培训
  • 网站建设 学生作业网络营销期末考试题库
  • 骗子会利用钓鱼网站做啥app推广一手单平台
  • 阿克苏网站建设公司东莞网站营销
  • 常州做网站yongjiawebseo能从搜索引擎中获得更多的
  • 如何建设一个国际化的网站宁波优化网页基本流程
  • 深圳网站建设php新手小白怎么做跨境电商
  • 中山市网站建设公司百度竞价排名是哪种方式
  • 建材招商网站seo图片优化
  • 搜索网站制作教程网站要怎么创建
  • 做网站需要域名还需要什么如何进行线上推广
  • 古田网站建设襄阳seo推广
  • 中小企业网站用什么技术青岛网站seo优化
  • 沧州wap网站制作中文域名交易网站
  • 网站开发招聘职位关键词优化排名首页
  • 美团网站除佣金表格怎么做百度关键词优化查询
  • wordpress 关于我们页面模板网站排名优化培训哪家好
  • 成都做一个小企业网站需要多少钱潍坊seo网络推广
  • 广西专业做网站的公司热搜词排行榜
  • 17网站一起做网店怎么样昨日凌晨北京突然宣布重大消息
  • 网站建设的总体设计思想抖音seo代理
  • 重庆最专业的房产网站建设百度投诉中心电话
  • 微信端网站开发流程常德网站建设制作
  • 网站内的搜索怎么做的百度极速版下载
  • app浏览器下载官方正版清理优化工具
  • 重庆最火的网站seo云优化软件破解版