资源简介
LINUX,系统编程,网络编程,网络聊天室。
利用SOCKET,发送,接收,等。
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “fun.h“
#define RET_OK 0
#define RET_ERR -1
#define LISTEN_QUEUE_NUM 5
#define BUFFER_SIZE 1024
#define ECHO_PORT 2029
int q;
/*功能:用户登录
参数:sockfd 客户端TCP套接字
p_onlinefd 服务器TCP连接后套接字的指针
username 登录名
onlinename 在线用户列表
返回值:成功返回0;失败返回-1*/
int client_login (int sockfd int *p_onlinefd char *username char *onlinename)
{
struct user me={“q““q“0};
struct user rgist={“q““q“1}; //保存注册信息的结构体;
int flag = 0; //1是成功,0是失败。
int flag1=0;
int a=0;
char code[20];
while(1)
{
if(flag1==1){
break;
}
system(“clear“);
system(“tput cup 11 33“); printf(“\t\033[34;1m********************************************************\n“);
system(“tput cup 12 33“); printf(“\t* 欢 迎 使 用 聊 天 系 统 v1.0 *\n“);
system(“tput cup 13 33“); printf(“\t*------------------------------------------------------*\n“);
system(“tput cup 14 33“); printf(“\t* 1、登 陆 *\n“);
system(“tput cup 15 33“); printf(“\t*------------------------------------------------------*\n“);
system(“tput cup 16 33“); printf(“\t* 2、注 册 *\n“);
system(“tput cup 17 33“); printf(“\t*------------------------------------------------------*\n“);
system(“tput cup 18 33“); printf(“\t* 3、退 出 *\n“);
system(“tput cup 19 33“); printf(“\t*------------------------------------------------------*\n“);
system(“tput cup 20 33“); printf(“\t* 请 选 择: *\n“);
system(“tput cup 21 33“); printf(“\t********************************************************\n“);
system(“tput cup 20 65“);
scanf(“%d“&a);
setbuf(stdinNULL);
//getchar();
switch(a)
{
case 1:
system(“clear“);
system(“tput cup 11 33“); printf(“\t\033[34;1m********************************************************\n“);
system(“tput cup 12 33“); printf(“\t* 请 登 录 *\n“);
system(“tput cup 13 33“); printf(“\t*------------------------------------------------------*\n“);
system(“tput cup 14 33“); printf(“\t* 用 户 名: *\n“);
system(“tput cup 15 33“); printf(“\t*------------------------------------------------------*\n“);
system(“tput cup 16 33“); printf(“\t* 密 码: *\n“);
system(“tput cup 17 33“); printf(“\t********************************************************\n“);
system(“tput cup 14 63“);
scanf(“%s“me.name);
//printf(“%s\n“me.name);
setbuf(stdinNULL);
system(“stty -echo“);
system(“tput cup 16 60“);
scanf(“%s“me.co
- 上一篇:数据仓库与数据挖掘 - 陈志泊
- 下一篇:编程之美高清经典
评论
共有 条评论