急!如何使用TCP方式进行一(Server)对多(Client)网络通信(200分)

  • 主题发起人 主题发起人 dream_flyer
  • 开始时间 开始时间
D

dream_flyer

Unregistered / Unconfirmed
GUEST, unregistred user!
写一个服务器客户端模式的程序,用到clientsocket和serversocket控件(或者直接用socket api)
我想在每次客户端对应服务器的一个线程,客户端对服务器产生连接请求时候产生线程
发送完之后结束该线程
使用多线程方式来处理每一个客户端的连接
最好有相关的demo
 
你看看例程和帮助。好象有。

主要就是TThreadList,实际就是TLIST继承。

除了YOURTHREAD,你需要的就是将YOURTHREAD类似ITEM,将它加入和减少。

 
TThreadList
As has been mentioned before, lists, stacks and queues are very common when
implementing communication between threads. The TThreadList class performs the
most basic sort of synchronization required between threads. In addition to all
the methods presented in TList, two extra methods are provided: Lock and Unlock.
The usage of these should be fairly obvious to readers who have managed to work
through the previous couple of chapters: The list is locked before being
manipulated, and unlocked afterwards. If a thread performs multiple operations
on the list that are required to be atomic, then the list must remain locked.
The list does not perform any implicit synchronization on objects which are owned
by a particular list. The programmer may wish to devise extra locking mechanisms
to provide this ability, or alternatively, use the lock on the list to cover all
operations on data structures owned by the list.
 
so so easy!!
做过n编了
 
都用TServerSocket的线程模式和TClientSocket的非组塞配合最好
 
后退
顶部