资源简介
a87367f4a675f35a12528fbaf99f3130.zip
![](http://www.nz998.com/pic/72067.jpg)
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define HOSTLEN 256
#define ROWS 23
#define COLS 80
int sock;
int connect_to_server(char *host int portnum){
int sock;
struct sockaddr_in servadd; /* the number to call */
struct hostent *hp; /* used to get number */
/** Step 1: Get a socket **/
sock = socket(AF_INET SOCK_STREAM 0); /* get a line */
if(sock == -1)
return -1;
/** Step 2: connect to server **/
bzero(&servadd sizeof(servadd)); /* zero the address */
hp = gethostbyname(host); /* lookup host‘s ip # */
if (hp == NULL)
return -1;
bcopy(hp->h_addr (struct sockaddr *)&servadd.sin_addr hp->h_length);
servadd.sin_port = htons(portnum); /* fill in port number */
servadd.sin_family = AF_INET ; /* fill in socket type */
if (connect(sock(struct sockaddr *)&servadd sizeof(servadd)) != 0)
return -1;
return sock;
}
void *send_oper(void *args){
char oper[1];
while(1){
oper[0] = getch();
write(sock oper 1);
}
}
main(int ac char *av[]){
char *cell;
sprintf(cell “%s“ av[3]);
if (ac < 4){
fprintf(stderr“usage: Missing parameters!\n“);
exit(1);
}
if(cell[0] == ‘o‘){
printf(“The cell can‘t be \“o\“!\n“);
exit(1);
}
sock = connect_to_server(av[1] atoi(av[2]));
if(sock == -1){
printf(“Connected failed!\n“);
exit(1);
}
write(sock av[3] 1);
initscr();
crmode();
noecho();
clear();
curs_set(0);
if(start_color() == OK){
init_pair(1COLOR_REDCOLOR_BLACK);
attron(COLOR_PAIR(1));
}
pthread_t thread;
pthread_create(&thread NULL send_oper NULL);
char screen[ROWS*COLS];
int i;
int n;
int index;
while(1){
n = read(sock &screen[index] ROWS*COLS-index);
index += n;
if(index == ROWS*COLS){
move(00);
for(i=0;i addch(screen[i]);
}
refresh();
index=0;
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 347598 2020-01-10 10:16 东北大学Linux大作业——贪吃蛇多人联机游戏\Linux 操作系统期末大作业.docx
文件 2008 2020-01-10 09:30 东北大学Linux大作业——贪吃蛇多人联机游戏\client.c
文件 8731 2020-01-10 09:04 东北大学Linux大作业——贪吃蛇多人联机游戏\server.c
目录 0 2020-02-04 11:49 东北大学Linux大作业——贪吃蛇多人联机游戏\
相关资源
- vspd7.2.308.zip
- 价值2k的H漫画小说系统
- Pythonamp;课堂amp;笔记(高淇amp;400;集第
- ddos压力测试工具99657
- UML建模大全
- 开源1A锂电池充电板TP4056原理图+PCB
- m1卡 ic卡可选择扇区初始化加密软件
- TSCC.exe
- FTP课程设计(服务端+客户端)
- 计算机图形学 边填充算法实现代码
- 电力系统潮流计算程序集合
- oracle数据迁移项目实施方案
- Web Api 通过文件流 文件到本地
- Visio图标-最新最全的网络通信图标库
- Spire API文档
- OpenGL参考手册
- Python中Numpy库最新教程
- SPD博士V5.3.exe
- 直流无刷电机方波驱动 stm32 例程代码
- layui后台管理模板
- 仿知乎界面小程序源代码
- 云平台-阿里云详细介绍
- photoshop经典1000例
- scratch垃圾分类源码(最终版本).sb
- IAR ARM 7.8破解
- TI CCS V5.4 安装步骤及破解文件
- 松下plc FP-XH的驱动
- 局域网硬件信息收集工具
- 加快Windows XP操作系统开机速度
- 联想启天M4350 BIOS升级文件
评论
共有 条评论