时
时报平
Unregistered / Unconfirmed
GUEST, unregistred user!
我看到设定ServerType 为stThreadBlocking时,delphi自带的帮助中提示如下:
Set ServerType to stThreadBlocking to automatically spawn a new thread for each socket connection accepted by the server socket. When ServerType is stThreadBlocking, the execution of the connection thread is suspended while reading or writing until all information has been transferred over the connection. The thread for each connection generates OnClientRead or OnClientWrite events when the server socket needs to read or write.
......
我想,OnClientRead 应该可以读取到socket中传来的数据,事实上,却根本不能接收到,
又在DFW里查了查,说是在ServerType 设为stThreadBlocking时,OnClientRead 不能接收到数据,要在OnGetThread事件中才能接收。
我试了试,果然如此,那么帮助中是不是有些误导呀,还是我理解错了?
我又看了帮助中对OnClientRead解释的部分,有以下内容
Note: If ServerType is stThreadBlocking, make sure that all code in an OnClientRead event handler is thread-safe. Use the GetClientThread method of the Sender parameter to access thread-specific information.
这里提到了使用GetClientThread 访问指定线程的信息,但还提到了在OnClientRead 事件中,代码要是线程安全的,但是实际OnClientRead 事件根本没有触发呀?
帮助中是不是有些误导呀,还是我理解错了?
Set ServerType to stThreadBlocking to automatically spawn a new thread for each socket connection accepted by the server socket. When ServerType is stThreadBlocking, the execution of the connection thread is suspended while reading or writing until all information has been transferred over the connection. The thread for each connection generates OnClientRead or OnClientWrite events when the server socket needs to read or write.
......
我想,OnClientRead 应该可以读取到socket中传来的数据,事实上,却根本不能接收到,
又在DFW里查了查,说是在ServerType 设为stThreadBlocking时,OnClientRead 不能接收到数据,要在OnGetThread事件中才能接收。
我试了试,果然如此,那么帮助中是不是有些误导呀,还是我理解错了?
我又看了帮助中对OnClientRead解释的部分,有以下内容
Note: If ServerType is stThreadBlocking, make sure that all code in an OnClientRead event handler is thread-safe. Use the GetClientThread method of the Sender parameter to access thread-specific information.
这里提到了使用GetClientThread 访问指定线程的信息,但还提到了在OnClientRead 事件中,代码要是线程安全的,但是实际OnClientRead 事件根本没有触发呀?
帮助中是不是有些误导呀,还是我理解错了?