用C Socket编程 [英] Socket programming in C

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

问题描述

一个以上的客户端进程将消息发送到服务器并反过来接收消息。一个客户端程序发送多条消息给服务器。现在,客户端进程发送一个消息,并以交错方式由服务器在接收到来自不同的客户端进程的消息每次连接到服务器

More then one client process sends messages to a server and receives messages in turn. One client process sends multiple messages to the server. Now, a client process connects to server each time a message is to be sent and messages from different client processes is received in an interleaved manner by server.

我如何识别客户端?我的意思是,一个客户端程序在服务器身份价值,是它一样。因为即使连接多次的过程。

How do I recognize a client? I mean, does a client process have an identity value in the server and is it the same for a process even though it connects multiple times.

感谢

推荐答案

除非你确定与仅由客户端的IP识别,你需要某种形式的令牌添加到通讯。可以(例如)添加一个消息给会话的开​​始哪些请求唯一令牌,然后要求将每个消息在从该客户机发送的相同的标记。

Unless you're ok with identifying by the client's IP only, you'll need to add some kind of token to the communication. You could (for example) add a message to the beginning of conversation which requests a unique token and then require the same token to be sent in every message from that client.

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

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