To :张无忌大侠 急!!!(100分)

  • 主题发起人 主题发起人 c96301
  • 开始时间 开始时间
C

c96301

Unregistered / Unconfirmed
GUEST, unregistred user!
早就听说你的大名,不知道能否帮忙解决一个问题。
能否发给我一个关于TserverSocket多线程处理TclientSocket发来请求的例子。
不胜感激。
 
在网上搜索delphi写的代理软件源代码,我见过的.
 
我回去找找看,找到了发个代码给你
 
代码我找到了,不过现在不能发给你,我没办法发啊,我在网吧!
 
能否给一份 ljf241@etang.com
 
能否发一个给我,我正急需
sfxt@vip.sina.com
 
To:张无忌
我的邮箱是c96301@sina.com,你的Socket例子能否发一份给我。不胜感激。
 
Threads for server connections are descendants of TServerSocketThread. Because of this, you can抰 use the New Thread object dialog. Instead, declare your thread manually as follows:

TMyServerThread = class(TServerClientThread);

To implement this thread, you override the ClientExecute method instead of the Execute method.
Implementing the ClientExecute method is much the same as writing the Execute method of the thread for a client connection. However, instead of using a client socket component that you place in your application from the Component palette, the server client thread must use the TTcpClient object that is created when the listening server socket accepts a client connection. This is available as the public ClientSocket property. In addition, you can use the protected HandleException method rather than writing your own thread-safe exception handling. For example:

procedure TMyServerThread.ClientExecute;

var
Stream : TWinSocketStream;
Buffer : array[0 .. 9] of Char;
begin
{ make sure connection is active }
while (not Terminated) and ClientSocket.Connected do
begin
try
Stream := TWinSocketStream.Create(ClientSocket, 60000);
try
FillChar(Buffer, 10, 0); { initialize the buffer }
{ give the client 60 seconds to start writing }
if Stream.WaitForData(60000) then

begin
if Stream.Read(Buffer, 10) = 0 then { if can't read in 60 seconds }
ClientSocket.Close; { close the connection }
{ now process the request }
...
end
else
ClientSocket.Close; { if client doesn't start, close }
finally
Stream.Free;
end;
except
HandleException;
end;

end;
end;

Warning: Server sockets cache the threads they use. Be sure the ClientExecute method performs any necessary initialization so that there are no adverse results from changes made when the thread last executed.

To use your thread, create it in an OnGetThread event handler. When creating the thread, set the CreateSuspended parameter to False.
 
张无忌大侠,
也给我发一份呀,救命用的,谢谢
dtj2000@mail.china.com
 
以上三位,我把代码都发给你们了,请查收!
 
张无忌,能不也给我一份??
 
嘿嘿,张无忌大大侠,我也要!!!见者有份.
dfw001@tom.com
 
我也要!
glint530@163.com
 
亲爱的张大侠,小妹喔也要啦!!!

odiedog@citiz.net
 
后退
顶部