Midas中的BUG, 无法捕捉SocketConnection连接失败的异常,造成程序死锁!快来帮帮我吧! (100分)

  • 主题发起人 LiChaoHui
  • 开始时间
Delphi帮助里面的又一点内容
Callbacks
Objects can make callbacks to clients and to other transactional objects.
For example, you can have an object that creates another object.
The creating object can pass a reference of itself to the created object;
the created object can then
use this reference to call the creating object.
If you choose to use callbacks, note the following restrictions:
Calling back to the base client or another package requires access-level
security on the client. Additionally, the client must be a DCOM server.
Intervening firewalls may block calls back to the client.
Workdo
ne on the callback executes in the environment of
the object being called. It may be part of the same transaction,
a different transaction, or no transaction.
Under MTS, the creating object must call SafeRef and pass
the returned reference to the created object in order to call back to itself.
 
http://bdn.borland.com/article/0,1410,29539,00.html
 
那段SupportCallbacks说得含糊不清,
When SupportCallbacks is True, the connection component can marshal calls
from the application server to the client application over an interface
supplied as a callback.
True时,客户端连接组件就会像接口回调一样调用应用服务器的函数。
又没有False的时候是怎么样的情况。supportcallbacks 又需要winsock2的支持什么什么。
都不知说些什么。
True, False的时候,客户端都会调用应用服务器的函数,我都怀疑它的回调是有返回值的
意思。。。
至于你说的各客户端通信,这样你看看行不行:
在远程数据模块中,OnCreate时,你就将当前客户端信息保存,形成链表。当一个客户
向一个客户发信息时,只是将信息放在应用服务器上那对应的客户端的数据模块中,每个
客户进行定时取这些数据吧。有点转发的味道。
我想不出其它办法来了。:(
 
我也不太懂在COM中进行CALLBACK的情况,看来已经可以实现COM的回调方法了,:),
还不如看看你那篇文章。
 
CALLBACK曾把我折腾过一次
//delphi4开发人员指南 的 下册 有一个例子//与SocketConnection无关
//可是配套光碟中 偏偏 缺 这个例子的代码
//以后 无意中 在 网上 发现 了 用 CALLBACK 写的聊天程序 才多少 了解 一点
 
呵呵,马上试了那例子,可行,试成了。
学了一招。[:D]
 
到此处取分吧
copy_paste
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1848198
hfghfghfg
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1848198
stuwe
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1848198
 
大家继续讨论吧,
假设,有n个客户端连接到应用服务器,
这时候某个客户端发送了一条消息, 应用服务器需要将其广播给其他所有的客户端,
每个为客户端服务的服务器端数据模块, 都在各自的线程空间中,
其中一个模块实例怎么,让其他的实例利用回调技术给客户端发送消息呢?
应该不能在一个数据模块中直接调用其他数据模块中的方法吧,
但是怎么给其他的数据模块发送消息或者通知其他数据模块呢,
要求资源占用尽可能的少
 
是广播?
还是P2P?
 
说的是广播, 但实际上不还是一个一个的 P2P 吗,
我说的就是一个一个的P2P怎么实现?
 
好像可以,你将
TComponentFactory.Create(ComServer, TCallBackRDM, Class_CallBackRDM, ciMultiInstance, tmApartment);
改成:
TComponentFactory.Create(ComServer, TCallBackRDM, Class_CallBackRDM, ciMultiInstance, tmFree);

就行了,我试了下。
要不留MAIL,我给你代码。
 
好吧, 把代码给我吧, 谢谢
li_violetcn@yahoo.con.cn
能给我讲一下 Apartment 和 Free 两种线程方式的却别吗?
我看帮助总看的不太明白
另: hfghfghfg 此处领分, 多谢
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1850103
 
For TSocketConnection, callbacks are optional. Set SupportCallbacks to True
if you are using callbacks as part of the application server抯 interface.
When SupportCallbacks is True, the socket connection component requires
WinSock2. Set SupportCallbacks to False if you are not using
callback functions and want to eliminate the dependency on WinSock2.
意思好像是说: 对于用 TSocketConnection 来说,CallBacks是附加的,如果你想将
CallBaks作为应用程序服务器的一部分,可以设定 SupportCallBacks 为 True. 当
SupportCallBack 为 True 时,Socket 连接组件需要 WinSock2 的支持, 如果你不
使用 CallBack 函数并且只是想仿真 WinSock2 的支持, 应设其为 False.
 
多放几天给需要的人看一下
 
程序已发。
tmSingle不用说啦
tmApartment
应用服务器确保一个时间内只能响应一个客户请求,虽然应用层的RDM是在不同的线程之内,
但每个RDM里只是调用本线程里面的是安全的,如果全局数据,必须使用同步技术来保护。
(可以使用threadvar变量进行访问)
tmFree
多线程模式,RDM能够在任意时间内响应客户的请求。当然RDM必须保护自己访问的数据是
安全的。(不要使用threadvar变量)
tmBoth
tmApartment + tmFree的组合,它根据客户端的进行自适应的调整。(好像是这个意思)
tmNeutral
(大长了,还不太明白)
tmApartment和tmFree的虽然都是多线程,但是在主线程调用的时候就会有区别了。
比如你的App Server是一个EXE,它响应了2个Client,那么它们两个都会创建两个RDM对象,
但区别就是EXE在tmApartment的情况下不能够同时访问这2个RDM,而tmFree可以。

在你所说的广播中,EXE是需要对全部RDM进行回调,那么就需要同时调用RDM中的回调,那
么tmApartment模型就是不适合的。
我写的测试程序中,如果是tmApartment,EXE调RDM回调的时候,总会说,什么什么被另一个
程序占用,不能访问之类的P话。呵呵
以上都是根据help所说的。不过我发给你的程序也证实了这一点。
 
真是太感谢了, 我这就去看你的程序
 
多人接受答案了。
 
LichaoHui,你收到MAIL程序没?
好像今天打回来了。。。。
原来你打错MAIL了,怪不得退回来了。
是yahoo.com.cn,你写成yahoo.con.cn
重发。。。
 
to LiChaoHui
闂??鐨勭粨鏋滀笉灏戒汉鎰忋
 

Similar threads

S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
967
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
回复
0
查看
1K
天地弦
顶部