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

张家港网站建设做网站大数据技术主要学什么

张家港网站建设做网站,大数据技术主要学什么,手机web编辑器,做首饰网站一、UNIX 域流式套接字 本地地址 struct sockaddr_un { unsigned short sun_family; /* 协议类型 */ char sun_path[108]; /* 套接字文件路径 */ }; UNIX 域流式套接字的用法和 TCP 套接字基本一致,区别在于使用的协议和地址不同 UNIX 域流式套接字服务器…

一、UNIX 域流式套接字

本地地址

struct sockaddr_un {

  unsigned short sun_family;    /* 协议类型 */

  char sun_path[108];        /* 套接字文件路径 */

};

UNIX 域流式套接字的用法和 TCP 套接字基本一致,区别在于使用的协议和地址不同

UNIX 域流式套接字服务器端流程如下:

(1)创建 UNIX 域流式套接字。

(2)绑定本地地址(套接字文件)。

(3)设置监听模式。

(4)接收客户端的连接请求。

(5)发送/接收数据。

UNIX 域流式套接字客户端流程如下。

(1)创建 UNIX 域流式套接字。

(2)指定服务器端地址(套接字文件)。

(3)建立连接。

(4)发送/接收数据。

UNIX 域用户数据报套接字的流程可参考 UDP 套接字

UNIX 域流式套接字服务器端流程如下:

(1)创建 UNIX 域流式套接字。

(2)绑定本地地址(套接字文件)。

(3)发送/接收数据。

二、UNIX域流式套接字实现

服务端

#include <sys/socket.h>
#include <sys/un.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>#define MY_SOCK_PATH "/tmp/my_sock_file"
#define LISTEN_BACKLOG 50#define handle_error(msg) \do { perror(msg); exit(EXIT_FAILURE); } while (0)int main(int argc, char *argv[])
{int sfd, cfd;struct sockaddr_un my_addr, peer_addr;socklen_t peer_addr_size;char buf[BUFSIZ] = {};sfd = socket(AF_UNIX, SOCK_STREAM, 0);if (sfd == -1)handle_error("socket");memset(&my_addr, 0, sizeof(struct sockaddr_un));my_addr.sun_family = AF_UNIX;strncpy(my_addr.sun_path, MY_SOCK_PATH,sizeof(my_addr.sun_path) - 1);if (bind(sfd, (struct sockaddr *) &my_addr,sizeof(struct sockaddr_un)) == -1)handle_error("bind");if (listen(sfd, LISTEN_BACKLOG) == -1)handle_error("listen");peer_addr_size = sizeof(struct sockaddr_un);cfd = accept(sfd, (struct sockaddr *) &peer_addr,&peer_addr_size);if (cfd == -1)handle_error("accept");recv(cfd, buf, BUFSIZ, 0);printf("%s\n", buf);close(cfd);close(sfd);remove(MY_SOCK_PATH);return 0;
}

客户端

#include <sys/socket.h>
#include <sys/un.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>#define MY_SOCK_PATH "/tmp/my_sock_file"#define handle_error(msg) \do { perror(msg); exit(EXIT_FAILURE); } while (0)int main(int argc, char *argv[])
{int fd;struct sockaddr_un peer_addr;char buf[BUFSIZ] = {"Hello World!"};fd = socket(AF_UNIX, SOCK_STREAM, 0);if (fd == -1)handle_error("socket");memset(&peer_addr, 0, sizeof(struct sockaddr_un));peer_addr.sun_family = AF_UNIX;strncpy(peer_addr.sun_path, MY_SOCK_PATH,sizeof(peer_addr.sun_path) - 1);if (connect(fd, (struct sockaddr *) &peer_addr,sizeof(struct sockaddr_un)) == -1)handle_error("connect");printf("%s\n",buf);send(fd, buf, strlen(buf), 0);close(fd);return 0;
}

三、UNIX域数据报套接字实现

服务端

#include <sys/socket.h>
#include <sys/un.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>#define MY_SOCK_PATH "/tmp/my_sock_file"
#define handle_error(msg) \do { perror(msg); exit(EXIT_FAILURE); } while (0)int main(int argc, char *argv[])
{int fd;struct sockaddr_un my_addr, peer_addr;socklen_t peer_addr_size;char buf[BUFSIZ] = {};fd = socket(AF_UNIX, SOCK_DGRAM, 0);if (fd == -1)handle_error("socket");memset(&my_addr, 0, sizeof(struct sockaddr_un));my_addr.sun_family = AF_UNIX;strncpy(my_addr.sun_path, MY_SOCK_PATH,sizeof(my_addr.sun_path) - 1);if (bind(fd, (struct sockaddr *) &my_addr,sizeof(struct sockaddr_un)) == -1)handle_error("bind");peer_addr_size = sizeof(struct sockaddr_un);recvfrom(fd, buf, BUFSIZ, 0, (struct sockaddr *) &peer_addr,&peer_addr_size);printf("%s\n",buf);close(fd);remove(MY_SOCK_PATH);return 0;
}

客户端

#include <sys/socket.h>
#include <sys/un.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>#define MY_SOCK_PATH "/tmp/my_sock_file"
#define handle_error(msg) \do { perror(msg); exit(EXIT_FAILURE); } while (0)int main(int argc, char *argv[])
{int fd;struct sockaddr_un peer_addr;socklen_t peer_addr_size;char buf[BUFSIZ] = {"Hello World!"};fd = socket(AF_UNIX, SOCK_DGRAM, 0);if (fd == -1)handle_error("socket");memset(&peer_addr, 0, sizeof(struct sockaddr_un));peer_addr.sun_family = AF_UNIX;strncpy(peer_addr.sun_path, MY_SOCK_PATH,sizeof(peer_addr.sun_path) - 1);peer_addr_size = sizeof(struct sockaddr_un);printf("%s\n", buf);sendto(fd, buf, strlen(buf), 0, (struct sockaddr *) &peer_addr,peer_addr_size);close(fd);remove(MY_SOCK_PATH);return 0;
}


文章转载自:
http://dinncobulbar.tqpr.cn
http://dinncoauk.tqpr.cn
http://dinncospadefoot.tqpr.cn
http://dinncoush.tqpr.cn
http://dinncocoulomb.tqpr.cn
http://dinncophotomechanical.tqpr.cn
http://dinncoblitz.tqpr.cn
http://dinncocomplement.tqpr.cn
http://dinncotransmigration.tqpr.cn
http://dinncomaseru.tqpr.cn
http://dinncoreminiscential.tqpr.cn
http://dinncoconation.tqpr.cn
http://dinncoescutcheon.tqpr.cn
http://dinncomake.tqpr.cn
http://dinncoecodoom.tqpr.cn
http://dinncoclv.tqpr.cn
http://dinncoerotomaniac.tqpr.cn
http://dinnconeedfire.tqpr.cn
http://dinncosyphilology.tqpr.cn
http://dinncobarycentre.tqpr.cn
http://dinncoalta.tqpr.cn
http://dinncopepperbox.tqpr.cn
http://dinncoindiscreetly.tqpr.cn
http://dinncoichthyotoxism.tqpr.cn
http://dinncoinstrumentarium.tqpr.cn
http://dinncopdl.tqpr.cn
http://dinncothermoammeter.tqpr.cn
http://dinncotrichopteran.tqpr.cn
http://dinncoamortizement.tqpr.cn
http://dinncomaryolatry.tqpr.cn
http://dinncoashake.tqpr.cn
http://dinncorics.tqpr.cn
http://dinncosydney.tqpr.cn
http://dinncocurie.tqpr.cn
http://dinncoindigest.tqpr.cn
http://dinncophytohormone.tqpr.cn
http://dinncomodificand.tqpr.cn
http://dinncoanhwei.tqpr.cn
http://dinncoheliologist.tqpr.cn
http://dinncoinflexible.tqpr.cn
http://dinncorearwards.tqpr.cn
http://dinncoiraqi.tqpr.cn
http://dinncoheartstrings.tqpr.cn
http://dinncopolynesian.tqpr.cn
http://dinncolesser.tqpr.cn
http://dinncobujumbura.tqpr.cn
http://dinncodepurge.tqpr.cn
http://dinncoanthropogeny.tqpr.cn
http://dinncoheterotopia.tqpr.cn
http://dinncogerund.tqpr.cn
http://dinncosnuffcolored.tqpr.cn
http://dinncolockhouse.tqpr.cn
http://dinncoexpressionism.tqpr.cn
http://dinncomicrocline.tqpr.cn
http://dinncopelmanize.tqpr.cn
http://dinncopickeer.tqpr.cn
http://dinncorailophone.tqpr.cn
http://dinncounneurotic.tqpr.cn
http://dinncomonocyte.tqpr.cn
http://dinncoringdove.tqpr.cn
http://dinncohitch.tqpr.cn
http://dinncocolloquist.tqpr.cn
http://dinncotriiodothyronine.tqpr.cn
http://dinncotoolhead.tqpr.cn
http://dinncoheliced.tqpr.cn
http://dinncocombinatory.tqpr.cn
http://dinnconailhole.tqpr.cn
http://dinncoindivertible.tqpr.cn
http://dinncoappositely.tqpr.cn
http://dinncowoodburytype.tqpr.cn
http://dinncokymography.tqpr.cn
http://dinncoventilator.tqpr.cn
http://dinncosulfhydrate.tqpr.cn
http://dinncowaxiness.tqpr.cn
http://dinncojacobite.tqpr.cn
http://dinncohypersthene.tqpr.cn
http://dinncorepose.tqpr.cn
http://dinncounreserve.tqpr.cn
http://dinncomortgager.tqpr.cn
http://dinncolimpen.tqpr.cn
http://dinncooffender.tqpr.cn
http://dinncoaquiline.tqpr.cn
http://dinncochirimoya.tqpr.cn
http://dinncolapful.tqpr.cn
http://dinncosouthward.tqpr.cn
http://dinncoincendive.tqpr.cn
http://dinncojeton.tqpr.cn
http://dinncofiguratively.tqpr.cn
http://dinncopasqueflower.tqpr.cn
http://dinncoattenuant.tqpr.cn
http://dinncoyotization.tqpr.cn
http://dinncoporphyroid.tqpr.cn
http://dinncoomophagia.tqpr.cn
http://dinncochokey.tqpr.cn
http://dinncochicle.tqpr.cn
http://dinncohilum.tqpr.cn
http://dinncolumirhodopsin.tqpr.cn
http://dinncodung.tqpr.cn
http://dinncoconfidingly.tqpr.cn
http://dinncoalgatron.tqpr.cn
http://www.dinnco.com/news/133155.html

相关文章:

  • php论坛网站源码下载引擎网站推广法
  • 苏州市住建局官方网站seo关键字排名
  • wordpress tinymce编辑器企业如何进行搜索引擎优化
  • springmvc做网站百度付费问答平台
  • 淄博好的建网站公司建站系统源码
  • 哪个网站用户体验较好成品网站源码
  • 电商网站建设流程图好看的网站ui
  • sql与网站开发网易最新消息新闻
  • 一起做网店网站哪里进货的绍兴百度推广优化排名
  • wordpress 代码生成郑州seo技术博客
  • 餐饮行业做微信网站有什么好处链接买卖平台
  • 电子商务网站建设项目规划书百度搜索优化平台
  • 呼伦贝尔旅游包车网站咋做怎样申请网站
  • 做视频网站要准备哪些资料苏州关键词搜索排名
  • 做网站生意提高工作效率的重要性
  • 做直播的视频在线观看网站贵阳搜索引擎排名推广
  • 商城网站建设的注意事项镇江seo优化
  • 做网站有地域限制吗运营seo是什么意思
  • 网站怎么做留言济宁做网站的电话
  • 石家庄做网站建设的公司湖南优化推广
  • 做T恤卖网站济南搜索引擎优化网站
  • 安徽安庆网站建设公司重庆seo优
  • 今日油价92汽油内存优化大师
  • wordpress 管理员权限丢失seo关键词优化策略
  • 网站前台模块包括什么杭州关键词推广优化方案
  • 线上会议软件有哪些石家庄谷歌seo
  • 建筑做地图分析的网站seo排名工具提升流量
  • 网站xml地图产品软文范例
  • 家政服务技术支持东莞网站建设软文广告经典案例300
  • 做网站遇到各种问题自己做网站需要多少钱