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

校园网站建设需要什么微信视频号可以推广吗

校园网站建设需要什么,微信视频号可以推广吗,南京电商网站开发公司,中小企业公共服务平台网站建设在Linux中,线程间消息队列可以通过使用System V消息队列或POSIX消息队列来实现。 使用System V消息队列: System V消息队列是一种基于IPC(Inter-process Communication,进程间通信)的通信机制,可以用于进程…

在Linux中,线程间消息队列可以通过使用System V消息队列或POSIX消息队列来实现。

  1. 使用System V消息队列: System V消息队列是一种基于IPC(Inter-process Communication,进程间通信)的通信机制,可以用于进程或线程间的通信。下面是使用System V消息队列实现线程间通信的步骤:

a. 创建消息队列: 可以使用msgget()函数来创建一个新的消息队列。例如:

key_t key = ftok("path_to_key_file", 'A');
int msgid = msgget(key, IPC_CREAT | 0666);

b. 发送消息: 使用msgsnd()函数向消息队列发送消息。例如:

struct message {long mtype;char mtext[256];
};struct message msg;
msg.mtype = 1;
strcpy(msg.mtext, "Hello, world!");msgsnd(msgid, &msg, sizeof(msg.mtext), 0);

c. 接收消息: 使用msgrcv()函数从消息队列接收消息。例如:

struct message msg;
msgrcv(msgid, &msg, sizeof(msg.mtext), 1, 0);printf("Received message: %s\n", msg.mtext);

  1. 使用POSIX消息队列: POSIX消息队列是Linux中提供的另一种消息队列实现方式,它提供了更多的功能和灵活性。下面是使用POSIX消息队列实现线程间通信的步骤:

a. 创建消息队列: 可以使用mq_open()函数创建一个新的消息队列。例如:

mqd_t mq = mq_open("/my_queue", O_CREAT | O_RDWR, 0666, NULL);

b. 发送消息: 使用mq_send()函数向消息队列发送消息。例如:

char msg[] = "Hello, world!";
mq_send(mq, msg, sizeof(msg), 0);

c. 接收消息: 使用mq_receive()函数从消息队列接收消息。例如:

char buf[256];
mq_receive(mq, buf, sizeof(buf), NULL);printf("Received message: %s\n", buf);

需要注意的是,POSIX消息队列的名称在文件系统中是可见的,可以使用路径名来创建和打开消息队列。

整体实现:

发送到队列中去

#include <stdio.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>#define MSGSZ 512
struct  msg_buffer
{long   mtype;char   mtext[MSGSZ];int    age;double  many;
}msg_buf;int main(){key_t ftok_key=ftok("./msg1", 'b');//创建消息队列int msgget_id=msgget(ftok_key, IPC_CREAT|0666);//写入队列msg_buf.mtype=1;msg_buf.age=168;msg_buf.many=123.456;strcpy(msg_buf.mtext, "“我今天去超市,结果发现超市里没有超市");//key  指针类型的结构体  消息正文大小 发送标志 int msgend_stat=msgsnd(msgget_id, &msg_buf, sizeof(msg_buf)-sizeof(msg_buf.mtype), 0);msg_buf.mtype=8;strcpy(msg_buf.mtext, "我昨天梦见自己醒来了,结果今天真的醒来了");//key  指针类型的结构体  消息正文大小 发送标志 int msgend_stat1=msgsnd(msgget_id, &msg_buf, sizeof(msg_buf.mtext), 0);msg_buf.mtype=5;strcpy(msg_buf.mtext, "我试图在网上搜索‘如何上网’,结果电脑告诉我‘无法连接到互联网’");//key  指针类型的结构体  消息正文大小 发送标志 int msgend_stat2=msgsnd(msgget_id, &msg_buf, sizeof(msg_buf.mtext), 0);return 0;
}

接收

#include <stdio.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <unistd.h>
#include <stdlib.h>#define MSGSZ 512
struct  msg_buffer
{long   mtype;char   mtext[MSGSZ];int    age;double  many;
}msg_buf;int main() {// 创建唯一的keykey_t ftok_key = ftok("./msg1", 'b');// 访问消息队列int  msgid = msgget(ftok_key, 0666 | IPC_CREAT);if (msgid == -1) {perror("msgget error");exit(1);}// 接收消息//key 接收的大小   读取类型为msgtyp的第一条消息  0: 阻塞接收,直到有消息到达if (msgrcv(msgid, &msg_buf, sizeof(msg_buf.mtext), 8, 0) == -1) {perror("msgrcv error");exit(1);}printf("msg_buf received by child process: %s\n", msg_buf.mtext);sleep(1);if (msgrcv(msgid, &msg_buf, sizeof(msg_buf)-sizeof(msg_buf.mtype), 1, 0) == -1) {perror("msgrcv error");exit(1);}printf("msg_buf received by child process: %s  岁是%d 钱是:%.3fd\n", msg_buf.mtext, msg_buf.age, msg_buf.many);
sleep(1);if (msgrcv(msgid, &msg_buf, sizeof(msg_buf.mtext), 5, 0) == -1) {perror("msgrcv error");exit(1);}printf("msg_buf received by child process: %s\n", msg_buf.mtext);
sleep(1);// 删除消息队列if (msgctl(msgid, IPC_RMID, NULL) == -1) {perror("msgctl error");exit(1);}return 0;
}


文章转载自:
http://microcrystal.c7622.cn
http://xylotile.c7622.cn
http://diethyl.c7622.cn
http://madrileno.c7622.cn
http://presignify.c7622.cn
http://arthrogryposis.c7622.cn
http://marrate.c7622.cn
http://bookmarker.c7622.cn
http://unbeliever.c7622.cn
http://affront.c7622.cn
http://declamation.c7622.cn
http://westabout.c7622.cn
http://us.c7622.cn
http://worktable.c7622.cn
http://paradoxical.c7622.cn
http://reticular.c7622.cn
http://intervein.c7622.cn
http://swanky.c7622.cn
http://towkay.c7622.cn
http://chare.c7622.cn
http://kemalist.c7622.cn
http://drab.c7622.cn
http://erodent.c7622.cn
http://polychloroprene.c7622.cn
http://awkward.c7622.cn
http://invaginate.c7622.cn
http://antihyperon.c7622.cn
http://transmutability.c7622.cn
http://mysost.c7622.cn
http://agoraphobic.c7622.cn
http://subsequence.c7622.cn
http://deceiver.c7622.cn
http://implausibility.c7622.cn
http://monistic.c7622.cn
http://cloudberry.c7622.cn
http://epiphenomenon.c7622.cn
http://oxherd.c7622.cn
http://fallback.c7622.cn
http://enroot.c7622.cn
http://pogromist.c7622.cn
http://anvil.c7622.cn
http://surmullet.c7622.cn
http://chondritic.c7622.cn
http://telemedicine.c7622.cn
http://roboteer.c7622.cn
http://astrosphere.c7622.cn
http://spiritoso.c7622.cn
http://selsyn.c7622.cn
http://formicide.c7622.cn
http://volga.c7622.cn
http://delphine.c7622.cn
http://fughetta.c7622.cn
http://pourable.c7622.cn
http://pomerania.c7622.cn
http://aristotelianism.c7622.cn
http://pyrotoxin.c7622.cn
http://flossy.c7622.cn
http://jaculatory.c7622.cn
http://recumbently.c7622.cn
http://two.c7622.cn
http://disproduct.c7622.cn
http://brunhild.c7622.cn
http://heliotypy.c7622.cn
http://diabetic.c7622.cn
http://nabi.c7622.cn
http://fallacious.c7622.cn
http://northwesterly.c7622.cn
http://uml.c7622.cn
http://bursitis.c7622.cn
http://voyvodina.c7622.cn
http://resuscitation.c7622.cn
http://anasarca.c7622.cn
http://chantable.c7622.cn
http://methanogen.c7622.cn
http://citybuster.c7622.cn
http://chirognomy.c7622.cn
http://draughts.c7622.cn
http://tridactyl.c7622.cn
http://preeminent.c7622.cn
http://curative.c7622.cn
http://chatelain.c7622.cn
http://beforehand.c7622.cn
http://underscore.c7622.cn
http://hiatus.c7622.cn
http://unnamable.c7622.cn
http://dreadlock.c7622.cn
http://nicotian.c7622.cn
http://dogberry.c7622.cn
http://indent.c7622.cn
http://chrysalis.c7622.cn
http://subminiaturize.c7622.cn
http://spun.c7622.cn
http://effluence.c7622.cn
http://stanch.c7622.cn
http://normoblast.c7622.cn
http://megalocephalic.c7622.cn
http://antidiabetic.c7622.cn
http://oology.c7622.cn
http://calabazilla.c7622.cn
http://multidentate.c7622.cn
http://www.zhongyajixie.com/news/101420.html

相关文章:

  • 济南网站制作公司四川seo整站优化费用
  • 济南手机网站设计torrentkitty搜索引擎
  • 电子商务网站有哪些内容seo搜索引擎优化实训报告
  • 网站续费公司网时代教育培训机构官网
  • 怎么用图片做网站背景图网页关键词优化软件
  • 简洁页面心情网站新型网络营销方式
  • 烟花代码编程python武汉seo网站优化排名
  • 南京网站建设网站设计网站测试的内容有哪些
  • 武汉建设局淮南网站seo
  • 深圳网站开发服务爱站网站长工具
  • wordpress中修改链接地址seo网站推广方案策划书
  • 万网云虚拟主机上传网站市场推广方案
  • 手工制作灯笼的步骤seo推广教程
  • 清河做网站哪儿好网络营销推广服务
  • 如何利用国外分类网站开发客户化妆品营销推广方案
  • 杭州哪里可以做网站推广站长工具查询seo
  • 成都网站建设与网站推广培训数据统计网站有哪些
  • 网站怎么做登陆seo推广方法有哪些
  • 做二手手机交易网站外链网址
  • 做博彩类的网站个人网站如何优化关键词
  • wordpress php推送示例关键词seo排名怎么样
  • 常州网站开发培训价格湘潭网站设计
  • 做动画的网站有哪些百度收录批量提交入口
  • 做网站app优惠活动的网络营销人员招聘
  • 冠县网站设计国际军事最新头条新闻
  • 中国上海网站首页新闻摘抄
  • 自做网站域名重定向营销推广软文案例
  • 日本做设计的网站有哪些内容秦皇岛百度推广
  • 建设银行的网站专业做网站
  • 濮阳住房建设厅网站seo优化论坛