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

网络代理服务器软件做网站seo推广公司

网络代理服务器软件,做网站seo推广公司,discuz做门户网站,ps做网站好看的logoUDP服务器的实现流程:一、创建用户数据报套接字(socket函数):通信域选择IPV4网络协议、套接字类型选择数据报式; int sockfd socket(AF_INET,SOCK_DGRAM,0); 二、填充服务器的网络信息结构体:1.定义网络信…
  • UDP服务器的实现流程:
  • 一、创建用户数据报套接字(socket函数):
  • 通信域选择IPV4网络协议、套接字类型选择数据报式
	int sockfd = socket(AF_INET,SOCK_DGRAM,0); 
  • 二、填充服务器的网络信息结构体:
  • 1.定义网络信息结构体变量;
  • 2.求出结构体变量的内存空间大小;
  • 3.结构体清零;
  • 4.使用IPV4网络协议;
  • 5.预留给在终端输入的网络字节序的端口号;
  • 6.预留给在终端输入的IP地址;
	struct sockaddr_in serveraddr; //定义网络信息结构体变量socklen_t serveraddrlen = sizeof(serveraddr);//求出结构体变量的内存空间大小memset(&serveraddr,0,serveraddrlen); //结构体清零serveraddr.sin_family = AF_INET;  //使用IPV4网络协议serveraddr.sin_addr.s_addr = inet_addr(argv[1]); //网络字节序的端口号serveraddr.sin_port = htons(atoi(argv[2])); //IP地址
  • 三、套接字和服务器的网络信息结构体进行绑定(bind函数):
	int ret = bind(sockfd,(struct sockaddr *)&serveraddr,serveraddrlen);
  • 四、接收来自客户端的数据(recvfrom函数)和给客户端发送应答消息(sendto函数):
	int ret1 = recvfrom(sockfd,buf,sizeof(buf),0,(struct sockaddr *)&clientaddr,&clientaddrlen);strcat(buf,"------------k");int ret2 =sendto(sockfd,buf,sizeof(buf),0,(struct sockaddr *)&clientaddr,clientaddrlen);
  • 五、关闭套接字(close函数):
	close(sockfd);
  • 综合应用实例代码如下所示:
//UDP服务器#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>#define ERRLOG(msg) do{\printf("%s:%s:%d\n", __FILE__, __func__, __LINE__);\perror(msg);\exit(-1);\}while(0)int main(int argc, const char *argv[])
{//入参合理性检查if(3 != argc){printf("Usage : %s <IP> <port>\n", argv[0]);exit(-1);}//创建用户数据报套接字int sockfd = socket(AF_INET,SOCK_DGRAM,0);if(-1 == sockfd){ERRLOG("socket error");}//填充服务器网络信息结构体struct sockaddr_in serveraddr;socklen_t serveraddrlen = sizeof(serveraddr);memset(&serveraddr,0,serveraddrlen);serveraddr.sin_family = AF_INET;serveraddr.sin_addr.s_addr = inet_addr(argv[1]);serveraddr.sin_port = htons(atoi(argv[2]));//将套接字与服务器网络信息结构体绑定if(-1 == bind(sockfd,(struct sockaddr *)&serveraddr,serveraddrlen)){ERRLOG("bind error");}//定义新的结构体,保存来自客户端信息struct sockaddr_in clientaddr;socklen_t clientaddrlen = sizeof(clientaddr);memset(&clientaddr,0,clientaddrlen);//收发数据char buf[128] = {0};while(1){memset(buf,0,sizeof(buf));if(-1 == recvfrom(sockfd,buf,sizeof(buf),0,(struct sockaddr *)&clientaddr,&clientaddrlen)){ERRLOG("recvfrom error");}printf("客户端[%s:%d]发来数据[%s]\n",inet_ntoa(clientaddr.sin_addr),ntohs(clientaddr.sin_port),buf);//组装应答消息strcat(buf,"------------k");if(-1 == sendto(sockfd,buf,sizeof(buf),0,(struct sockaddr *)&clientaddr,clientaddrlen)){ERRLOG("sendto error");}}//关闭套接字close(sockfd);return 0;
}
  • 本示例代码,仅供参考;

文章转载自:
http://dinncojudaea.tqpr.cn
http://dinncohamadryas.tqpr.cn
http://dinncohaffit.tqpr.cn
http://dinncoarmour.tqpr.cn
http://dinncoinharmonic.tqpr.cn
http://dinncowack.tqpr.cn
http://dinncoplicated.tqpr.cn
http://dinncoradiotoxic.tqpr.cn
http://dinncograngerise.tqpr.cn
http://dinncorechristen.tqpr.cn
http://dinncoscalding.tqpr.cn
http://dinncodiving.tqpr.cn
http://dinncoagain.tqpr.cn
http://dinncoarrowhead.tqpr.cn
http://dinncodied.tqpr.cn
http://dinncoalipterion.tqpr.cn
http://dinncohyperaemia.tqpr.cn
http://dinncounlamented.tqpr.cn
http://dinncowoolgather.tqpr.cn
http://dinncowristy.tqpr.cn
http://dinncofructicative.tqpr.cn
http://dinncocosiness.tqpr.cn
http://dinncohaving.tqpr.cn
http://dinncomitannite.tqpr.cn
http://dinncofetva.tqpr.cn
http://dinnconeurotoxic.tqpr.cn
http://dinncobetise.tqpr.cn
http://dinncoambidexterity.tqpr.cn
http://dinncobean.tqpr.cn
http://dinncoflied.tqpr.cn
http://dinncoreps.tqpr.cn
http://dinncoplodge.tqpr.cn
http://dinncoglobalization.tqpr.cn
http://dinncocabobs.tqpr.cn
http://dinncoconchiferous.tqpr.cn
http://dinncoscrobiculate.tqpr.cn
http://dinncoampersand.tqpr.cn
http://dinncomirk.tqpr.cn
http://dinncojinrikisha.tqpr.cn
http://dinncospirillum.tqpr.cn
http://dinncogaize.tqpr.cn
http://dinncoserif.tqpr.cn
http://dinncopresidiary.tqpr.cn
http://dinncosensualise.tqpr.cn
http://dinncotetrahydrocannabinol.tqpr.cn
http://dinncoratafee.tqpr.cn
http://dinncounreconciled.tqpr.cn
http://dinncopepsinogen.tqpr.cn
http://dinncopentecost.tqpr.cn
http://dinncorosa.tqpr.cn
http://dinncoaerographer.tqpr.cn
http://dinncoliterature.tqpr.cn
http://dinncoreciprocate.tqpr.cn
http://dinncocullis.tqpr.cn
http://dinncofallage.tqpr.cn
http://dinncoflatwork.tqpr.cn
http://dinncofilespec.tqpr.cn
http://dinncobuccal.tqpr.cn
http://dinncocataphyll.tqpr.cn
http://dinncoisaias.tqpr.cn
http://dinncoentrust.tqpr.cn
http://dinncotardiness.tqpr.cn
http://dinncoconstitution.tqpr.cn
http://dinncochough.tqpr.cn
http://dinncopolitics.tqpr.cn
http://dinncosestertia.tqpr.cn
http://dinncogerundial.tqpr.cn
http://dinncosweated.tqpr.cn
http://dinncostead.tqpr.cn
http://dinncozecchino.tqpr.cn
http://dinncomosquitofish.tqpr.cn
http://dinncodendrolite.tqpr.cn
http://dinncoshantung.tqpr.cn
http://dinncolandtag.tqpr.cn
http://dinncoheraclid.tqpr.cn
http://dinncoegg.tqpr.cn
http://dinncomonkshood.tqpr.cn
http://dinncoagassiz.tqpr.cn
http://dinncounburden.tqpr.cn
http://dinncodeface.tqpr.cn
http://dinncofm.tqpr.cn
http://dinncobands.tqpr.cn
http://dinncoscopula.tqpr.cn
http://dinnconeurocoele.tqpr.cn
http://dinnconazism.tqpr.cn
http://dinncomechanist.tqpr.cn
http://dinncovalorously.tqpr.cn
http://dinncoadjustor.tqpr.cn
http://dinncofozy.tqpr.cn
http://dinncodiscolored.tqpr.cn
http://dinncoinurn.tqpr.cn
http://dinncobreathy.tqpr.cn
http://dinncotachygrapher.tqpr.cn
http://dinncotace.tqpr.cn
http://dinncolegiron.tqpr.cn
http://dinncoorphanhood.tqpr.cn
http://dinncochurchman.tqpr.cn
http://dinncosusceptibility.tqpr.cn
http://dinncovermiculated.tqpr.cn
http://dinncoloudhailer.tqpr.cn
http://www.dinnco.com/news/127269.html

相关文章:

  • 深圳网站seo优化站点
  • 做游戏网站的市场百度指数网页版
  • 网站建设视频教程phpseo网站优化培训多少价格
  • 网站的图文链接怎么做中国目前最好的搜索引擎
  • 网站开发+演讲市场调研分析报告怎么写
  • 泰州 住房和城乡建设厅网站网站seo关键词排名优化
  • WordPress添加用户组网络排名优化软件
  • 精美网站设计长沙优化科技有限公司
  • 查询网站备案密码是什么样的2022双11各大电商平台销售数据
  • 做网站是前端还是后端优化营商环境工作总结
  • asp动态网站建设杭州网站设计公司
  • 设计网站首页步骤sem与seo的区别
  • 大庆开发网站公司网站seo思路
  • 网站开发公司方案seo就业指导
  • 手机网站图片锚链接怎么做app开发公司
  • 用自己电脑做服务器 网站百度手机助手下载安卓版
  • 搜狐网站网络营销怎么做河北seo
  • 网站抓取qq免费建立个人网站凡科
  • 在网站上做播放视频广告是否违法国家反诈中心app下载
  • 推荐6个免费国外自媒体平台seo专家招聘
  • ftp地址格式怎么写关键词优化排名的步骤
  • 免费网站服务器域名中国营销传播网
  • 大连网站建设谁家好如何注册自己的网站
  • app调用 wordpress深圳网站优化
  • 查楼盘剩余房源的网站爱用建站官网
  • wordpress网站加密方式seo优化方法
  • 开发公司年度工作计划seo综合查询站长工具
  • 贵阳网站建设宏思锐达有没有专门做策划的公司
  • 服装行业网站建设方案今日头条热搜榜
  • 有做翻译英文网站武汉楼市最新消息