TCP服务器从列表中向未选择的客户端发送消息. [英] TCP Server sending Message to non selected clients from the list.

查看:128
本文介绍了TCP服务器从列表中向未选择的客户端发送消息.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设计了一个基于客户端服务器TCP/IP Windows的应用程序.
我的服务器在列表框控件中有一个实时IP(连接到服务器的IP)列表.
我键入一条消息,然后从列表框中选择一些IP,每10次中有9次可以正常工作.
但是有时问题出在所选IP的一个IP不能接收到消息,而是列表框中的其他IP从接收到的IP消息却未被选中.
此问题随机出现.
但是对于这个问题,我的应用程序不可靠.
我想使其可靠.


在此先感谢..

I have Designed a Client Server TCP/IP windows based application.
My server has a list of live IP''s (IP''s which are connected to server) in the listbox control.
I type a Message and select some IP''s from the listbox it works fine every 9 out of 10 times.
But Sometimes problem comes from the selected IP''s one IP doesnot get the message and instead that IP some other Random IP from the Listbox receives the message though not selected.
This issue comes Randomly.
But for this issue my application cannot be Reliable.
I want to make it reliable.


Thanks in advance..

推荐答案

听起来像同步问题,并且您正在使用列表框中的元素索引来映射到内部列表的索引.服务器,这不同步.当新客户端连接或断开连接时会发生这种情况吗?

尝试将对象存储在列表中,该列表包含您需要知道的所有客户端信息,并使用SelectedItem而不是SelectedIndex(或多选等效项,即使用项目而不是项目索引).
Sounds like a synchronisation problem, and you''re using indices of elements in the list box to map to indices of an internal list in the the server, which get out of sync. Does this happen when a new client connects or drops?

Try storing an object in the list which has all the information you need to know which client it is, and use SelectedItem instead of SelectedIndex (or the multi-select equivalent, i.e. use the item not the item index).


这篇关于TCP服务器从列表中向未选择的客户端发送消息.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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