1. 忆年共享相册:忆年是一款为用户提供免费的照片存储及消梁共享的应用软件。界面非常简洁,可点击底部按钮生成相册,原图照片都储存在云端,不过期,支持批量上传和下载。在微信中一键邀请分享,能够和亲朋好友共享照片。
2. 云梦助没桥运眠引导:它是一款有专业音乐人打造的音频助眠应用。清爽的页面设计,精选了10个睡眠场景。舒缓的音乐+白噪音+人声催眠,专业度高。晚上睡不着觉是最让人头疼的事情了,这款专业的软件可以伴你迅速入眠。
3. 番茄闹钟:有别于一般的闹钟,你可以在接下来的25分钟选择一个任务然后专注的做这件事,番茄闹钟会开始计时。同枯梁时提供白噪音,让人专心沉浸在事物中。能够有效地使人集中精力做一件事,随时保持克制。
源码如下://chat_one.c
#include <sys/types.h>
#include <sys/socket.h>衫让团
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <malloc.h>或橘
#include <sys/select.h>
int main( int argc, char **argv)
{
struct sockaddr_in chatone, chattwo
char pmsg[1000]
char *buf
intchatone_fd
intret,i
intlen, msg_len
fd_set fdset
if ( argc <2 ){
printf("please input ip address\n")
return -1
}
printf("server address is %s\n", argv[1])
chattwo.sin_family = AF_INET
chattwo.sin_port = htons(60002)
inet_pton(AF_INET, argv[1], &chattwo.sin_addr.s_addr)
chatone.sin_family = AF_INET
chatone.sin_port = htons(60000)
chatone.sin_addr.s_addr = INADDR_ANY
chatone_fd = socket(PF_INET, SOCK_DGRAM, 0)
if ( -1 == chatone_fd ){
printf("create socket failed %s\n", strerror(errno))
return -1
}
ret = bind(chatone_fd, (struct sockaddr *)&chatone, sizeof(chatone))
if ( -1 == ret){
printf("bind failed %s \n", strerror(errno))
return -1
}
for(i=0i<1000i++){
FD_ZERO( &fdset )
FD_SET ( 0, &fdset)
FD_SET( chatone_fd, &fdset)
if ( -1 == select ( chatone_fd+1, &fdset, NULL, NULL, NULL) ){
continue
}
if ( FD_ISSET( chatone_fd, &fdset)){
recvfrom( chatone_fd, pmsg, 999, 0, NULL, 0)
printf("receive %s\n", pmsg)
}
else{
memset( pmsg, 0, 1000)
fgets(pmsg, 999, stdin)
len = sizeof(chattwo)
sendto( chatone_fd, pmsg, 1000, 0,\
(struct sockaddr*) &chattwo, len)
printf("send %s\n", pmsg)
}
}
printf("sent %d packets\n", i)
close(chatone_fd)
return 0
}
//chat_two.c
#include <sys/types.h>
#include <sys/滑蚂socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <malloc.h>
#include <sys/select.h>
int main( int argc, char **argv)
{
struct sockaddr_in chatone, chattwo
char pmsg[1000]
char *buf
intchattwo_fd
intret,i
intlen, msg_len
fd_set fdset
if ( argc <2 ){
printf("please input ip address\n")
return -1
}
printf("server address is %s\n", argv[1])
chattwo.sin_family = AF_INET
chattwo.sin_port = htons(60002)
chattwo.sin_addr.s_addr = INADDR_ANY
chatone.sin_family = AF_INET
chatone.sin_port = htons(60000)
inet_pton(AF_INET, argv[1], &chatone.sin_addr.s_addr)
chattwo_fd = socket(PF_INET, SOCK_DGRAM, 0)
if ( -1 == chattwo_fd ){
printf("create socket failed %s\n", strerror(errno))
return -1
}
ret = bind(chattwo_fd, (struct sockaddr *)&chattwo, sizeof(chattwo))
if ( -1 == ret){
printf("bind failed %s \n", strerror(errno))
return -1
}
for(i=0i<1000i++){
FD_ZERO( &fdset )
FD_SET ( 0, &fdset)
FD_SET( chattwo_fd, &fdset)
if ( -1 == select ( chattwo_fd+1, &fdset, NULL, NULL, NULL) ){
continue
}
if ( FD_ISSET( chattwo_fd, &fdset)){
recvfrom( chattwo_fd, pmsg, 999, 0, NULL, 0)
printf("receive: %s\n", pmsg)
}
else{
memset( pmsg, 0, 1000)
fgets(pmsg, 999, stdin)
len = sizeof(chatone)
sendto( chattwo_fd, pmsg, 1000, 0,\
(struct sockaddr*) &chatone, len)
printf("send %s\n", pmsg)
}
}
printf("sent %d packets\n", i)
close(chattwo_fd)
return 0
}
编译好这个两个程序就可以进行简单的通信了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)