資源簡介
網絡聊天室源碼,有需要的可以下載下來看一下,實現的功能有群聊私聊,管理員模式,禁言模式,并附Mysql數據庫API

代碼片段和文件信息
/*************************************************************************
>?File?Name:?client.c
>?Author:?
>?Mail:?
>?Created?Time:?2019年11月18日?星期一?09時38分35秒
?************************************************************************/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
/*全局變量定義區*/
#define?PORT?6666
#define?IP???“127.0.0.1“
int?num_bflognum?=?0;
int?retsocknewlensockid;
pthread_attr_t?attr;
struct?sockaddr_in?Chat_inf;
pthread_t?pthid_creatpthid_loginpthid_forgetpthid_wpthid_rpthid_leavepthid_onpthid_grouppthid_privatepthid_allpthid_Rpthid_his;
struct?HIS{
????char?history[256];//歷史消息
????int?num;//功能類型
????int?flag;//私聊回復
????int?GC;//群聊標志位
????int?PC;//私聊標志位
????char?Me[20];//客戶端ID
????char?object[10];//私聊對象/群聊中禁言對象
????int?JY;//申請標志位(1為未同意0為同意)
};
struct?HIS?Note;
struct?INF{
????char?name[20];//昵稱(名字是root或者是ROOT的昵稱代表是管理員)
????char?pwd[10];//密碼
????char?pwd_mark[100];//密保問題
????char?pwd_point[100];//密保答案
????int?power;//登錄成功的標志(1在線0離線)
????int?sock;//登錄時的通信套接字
};
struct?INF?inf;//詳細信息結構體
/*子函數定義區*/
void?list_1(void);//登錄注冊界面的顯示函數
void?list_2(void);//主界面的顯示函數
void?*Create_account(void*?arg);//創建賬號
void?*Log_in(void*?arg);//帳號密碼登錄
void?*Forget_pwd(void*?arg);//忘記密碼
void?*Read(void*?arg);//讀進程
void?*Write(void*?arg);//寫進程
void?*Group_chat(void*?arg);//群聊
void?*Private_chat(void*?arg);//私聊申請
void?*On_line(void*?arg);//此時在線人數
void?*Off_line(void*?arg);//離線
void?*All(void*?arg);//list2有東西就接受
void?*Peron(void*?arg);//私聊函數
void?*READ(void*?arg);//私聊讀函數
void?*Group_history(void*?arg);//群聊歷史消息
void?list_1(void)
{
????printf(“1.注冊帳號\n“);
????printf(“2.帳號密碼登錄\n“);
????printf(“3.忘記密碼\n“);
????printf(“0.退出系統\n“);
}
void?list_2(void)
{
????printf(“********************\n“);
????printf(“用戶:%s?歡迎您的使用!\n“inf.name);
????printf(“********************\n“);
????printf(“4.顯示當前在線\n“);
????printf(“5.群聊\n“);
????printf(“6.私聊\n“);
????printf(“7.離線\n“);
????printf(“8.查看申請消息\n“);
????printf(“9.清屏\n“);
????printf(“10.查看歷史群聊記錄\n“);
}
void?*Create_account(void*?arg)
{
????int?fd?=?*(int?*)arg;
????int?flag;
????int?boom;
????int?shark?=?0;
????char?Account[20]={0};
????send(fd&Notesizeof(Note)0);
????printf(“歡迎進入賬戶注冊\n“);
Name:????
????printf(“請創建昵稱\n“);
????scanf(“%s“inf.name);
/*????send(fd&inf.namesizeof(inf.name)0);
????recv(fdAccountsizeof(Account)0);
????if(strcmp(inf.nameAccount)?==?0)
????{
????????printf(“該昵稱已被占用\n“);
????????shark?=?1;
????????send(fd&sharksizeof(int)0);
????????goto?Name;
????}
????shark?=?0;
????send(fd&sharksizeof(int)0);
*/
????printf(“請創建密碼\n“);
????scanf(“%s“inf.pwd);
/*????printf(“請選擇是否設置密保\n1.設置\n2.跳過\n“);
????scanf(“%d“&flag);
????if(flag?==?2)
????{
????????printf(“正在跳過密保設置\n“);
????????goto?JUMP;
????}
????*/
????printf(“請設置密保問
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????19024??2019-11-26?11:59??網絡聊天室源代碼\chat\c
?????文件??????14963??2019-12-26?19:34??網絡聊天室源代碼\chat\client.c
?????文件?????????81??2019-11-25?09:46??網絡聊天室源代碼\chat\makefile
?????文件??????23208??2019-11-26?11:59??網絡聊天室源代碼\chat\s
?????文件??????15957??2019-12-26?19:39??網絡聊天室源代碼\chat\server.c
?????文件????????157??2019-12-23?20:02??網絡聊天室源代碼\chatroom_ESC\1.txt
?????文件??????21984??2019-12-23?20:02??網絡聊天室源代碼\chatroom_ESC\a.out
?????文件??????18744??2019-12-23?20:02??網絡聊天室源代碼\chatroom_ESC\c
?????文件??????13561??2019-12-23?20:02??網絡聊天室源代碼\chatroom_ESC\client.c
?????文件??????22616??2019-12-23?20:02??網絡聊天室源代碼\chatroom_ESC\s
?????文件??????35029??2019-12-23?20:02??網絡聊天室源代碼\chatroom_ESC\server.c
?????文件???????1328??2019-12-19?11:08??網絡聊天室源代碼\蘇曉東\all.h
?????文件??????24612??2019-12-24?11:33??網絡聊天室源代碼\蘇曉東\client.c
?????文件???????1277??2019-12-23?15:21??網絡聊天室源代碼\蘇曉東\readme.txt
?????文件??????15546??2019-12-24?16:42??網絡聊天室源代碼\蘇曉東\server.c
?????目錄??????????0??2019-12-26?19:30??網絡聊天室源代碼\chat
?????目錄??????????0??2019-12-23?21:14??網絡聊天室源代碼\chatroom_ESC
?????目錄??????????0??2019-12-25?16:19??網絡聊天室源代碼\蘇曉東
?????目錄??????????0??2019-12-26?19:30??網絡聊天室源代碼
-----------?---------??----------?-----??----
???????????????228087????????????????????19
- 上一篇:一個簡單的LabVIEW 登錄界面
- 下一篇:簡易人事管理系統pyqt5+mysql
評論
共有 條評論