资源简介
基于嵌入式linux的网络聊天室的实现,有详细的软件设计文档,用户手册,及源码

代码片段和文件信息
/* client.c
*
* data:07-02-07
*
* version:1.3
* */
#include“sec_group.h“
#include“client.h“
#include“client_online_list.h“
#include “gui.h“
#include “msg_list.h“
#include “write_record.h“
#define port 8001
char TOWHO[20];
void thread(int sock_fd);
void record_select(void);
/*------------------------------------*/
void first_print_select(int fd);
void client_load_deal(int sock_fd);
void client_reg_deal(int sock_fd);
void client_command_to(char * bufchar * name);
void client_command_quit(int fd);
void use_command_to_deal(char *buf);
/*-----------------------------------------*/
/* the first *//* 1^*/
/* include two function to make a link */
int main(int argc char *argv[])
{
int wild_sock_fd;
client_help(argcargv);
memset(TOWHO020);
wild_sock_fd = create_connect_server();
deal_connect(wild_sock_fd);
return 0;
}
/*-----------------------------------------*/
/* the two *//* 2^*/
/* create the connet it didn‘t have another function*/
int create_connect_server(void)
{
struct sockaddr_in pin;
int sock_fd;
int n;
bzero(&pin sizeof(pin));
pin.sin_family = AF_INET;
inet_pton(AF_INET IP &pin.sin_addr);
pin.sin_port = htons(port);
sock_fd = socket(AF_INET SOCK_STREAM 0);
if(sock_fd == -1)
{
perror(“call to socket“);
exit(1);
}
n = connect(sock_fd (void *)&pin sizeof(pin));
if(n == -1)
{
perror(“call to connect“);
exit(1);
}
return sock_fd;
}
void *thr_gui(void *arg)
{
gui_main();
}
/* you see the first from the client */
void first_print_select(int fd)
{
int ch;
int client_select_flag = 0;
do
{
printf(“\nplease input \‘r\‘ to register and input \‘l\‘ to load \n“);
ch = getchar();
while((getchar()) != ‘\n‘);
if(ch == ‘r‘)
{
client_reg_deal(fd);
client_select_flag = 1;
}
else if(ch == ‘l‘)
{
client_load_deal(fd);
client_select_flag = 1;
}
}while(client_select_flag != 1);
}
/* create a pthread to deal the chat */
void deal_connect(int sock_fd)
{
int id;
int n;
pthread_t tid;
char buf[MAXLINE];
first_print_select(sock_fd);
if( 0 != pthread_create(&tid NULL thr_gui NULL) )
{
printf(“can not create gui!\n“);
exit(1);
}
usleep(200);
pthread_create((void *)&idNULL(void *)thread(void *)sock_fd);
while(1)
{
read_from_client(buf);
client_information_judge_deal(bufsock_fd);
write_to_server(bufsock_fd);
memset(buf0MAXLINE);
}
n = close(sock_fd);
if(n == -1)
{
perror(“call to close“);
exit(1);
}
exit(0);
}
/*----------------------------------------------*/
/* the third *//*3^*/
/* the pthread function circle to read and the write to client */
void thread(int sock_fd)
{
int n;
char *buf = (char *)malloc(MAXLINE);
while(1)
{
memset(buf0MAXLINE);
n = read_from_server(sock_fdbuf);
if( n == -1)
{
perror(“call to read“);
exit(1);
}
if((buf[0] == ‘9‘ && buf[1] == ‘9‘) || (buf[0]== ‘8‘ && buf[1] == ‘8‘))
{
plist new;
new =(plist) malloc (sizeof(str
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 364032 2008-09-09 21:04 em
文件 668672 2007-02-09 14:16 em
文件 11528 2007-02-12 15:01 em
文件 39595 2007-02-09 14:48 em
文件 9295 2007-02-09 12:48 em
文件 665 2007-02-08 14:14 em
文件 280 2007-02-08 14:10 em
文件 2944 2007-02-09 09:15 em
文件 3208 2007-02-09 14:17 em
文件 407 2007-02-08 14:24 em
文件 4612 2007-02-09 14:48 em
文件 4507 2007-02-07 21:05 em
文件 108 2007-02-06 18:23 em
文件 235 2007-02-09 09:15 em
文件 1034 2007-02-08 21:58 em
文件 270 2007-02-08 21:56 em
文件 336 2007-02-09 10:36 em
文件 900 2007-02-09 16:04 em
文件 512 2007-02-08 21:18 em
文件 109 2007-02-08 21:51 em
文件 39667 2007-02-09 11:32 em
文件 76635 2007-02-09 10:19 em
文件 70043 2007-02-09 10:47 em
文件 363008 2008-07-14 20:24 em
文件 668672 2007-02-09 14:16 em
文件 50 2007-02-09 11:29 em
文件 221 2007-02-09 09:44 em
文件 219 2007-02-09 15:56 em
文件 4169 2007-02-09 16:19 em
文件 460 2007-02-09 09:44 em
............此处省略25个文件信息
相关资源
- Micrium.RTOS.1.0.0.pack
- uboot到linux logo显示不间断 补丁
- ISE_14.7_license.lic
- stm32f103c8t6 4 oled.rar
- mpu6050+hmc5883L.rar
- UNIX/LINUX编程实践教程的源码
- 嵌入式图形界面MiniGUI的示例程序9例
- Linux任务管理器
- linux应用层的华容道游戏源代码
- ubuntu9.10 可加载内核模块和字符设备驱
- MP3文件ID3v2ID3v2APEv2标签读取
- ARM嵌入式项目实战
- 操作系统实验——虚存管理实验
- linux下的发包工具sendip
- 尚观培训linux许巍关于c 的笔记和讲义
- 尚观培训linux董亮老师关于数据结构的
- linux 线程池源码 c 版
- linux C 电梯程序练习
- linux下用多进程同步方法解决生产者
- uCOS编译环境建立 BC45 TASM
- Linux 操作系统实验(全)
- Linux From Scratch 中文手册
- linux 网络实验 ftp程序
- Linux命令大全离线版&在线版
- 操作系统共享内存实验
- dos 下运行Linux 命令--gnu_utils
- stm32 用SPI 方式读写 SDHC
- linux 0.12内核源代码
- linux简易shell C实现
- linux实验报告及心得体会
评论
共有 条评论