聊天应用程序在c [英] chat application in c

查看:93
本文介绍了聊天应用程序在c的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我是计算机科学专业的学生,​​我在linux中使用c开发了一个客户端服务器聊天应用程序。我的客户端和服务器都是多线程的,可以同时发送和接收数据。现在我想我的服务器应该能够在客户端之间传递数据。当客户端连接到服务器时,服务器应该将所有可用客户端的列表发送给它,客户端应该能够选择它想要通信的客户端..请给我一步一步的描述,我应该怎么做..我应该为此目的创建一个数据库,还是可以用文件来完成?

解决方案

数据库是一种更好的方法,因为它处理搜索和删除比平面文本文件更容易:但实际上您并不特别需要:连接客户端的内存中集合可能就是您所需要的。由于套接字连接在应用程序关闭后不会保留,因此服务器将始终以空客户端列表开头 - 那么为什么还需要保留谁连接?数据

hi i am student of computer science i have developed a client server chat application using c in linux. my client and server both are multi threaded both can send and receive data at same time. now i want that my server should be able to pass data between the clients . when a client is connected to the server the server should send the list of all available clients to it and client should be able to select the client to which it wants to communicate.. please give me step by step description that how should i do it.. shall i create a database for this purpose or it can be done with a file??

解决方案

A database is a better approach, as it handles searching and deletions more easily than a flat text file: but in reality you don't particularly need either: an in-memory collection of connected clients is probably all you need. Since the socket connections would not be persisted once the application closes, your server will always start with an empty client list - so why would you need to persist the "who-is-connected?" data?


这篇关于聊天应用程序在c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆