关于多线程下的FTP(200分)

B

Bcbhua

Unregistered / Unconfirmed
GUEST, unregistred user!
能同时与一个FTP服务器建立多个连接吗?也就是说每个线程都与服务器建立一个连接!
如果不行,那该如何实现多线程FTP?
如果用WINSOCK的话,能多次对同一个服务器和端口调用connect吗?即多线程,各个线程都
与服务器建立一个连接!
 
这个我做过,是完全可以的,
DELPHI有一个关于多线程的例子,还有FTP控件
两个结合一下就可以了
注意线程结束时的资源释放
 
可以多次对同一个服务器和端口调用connect,因为作为服务器端监听的server socket在有
connect请求到来后,会为每一个连接创建一个新的socket,真正的用户数据是和这个socket
交互的。在delphi里,如果你用tserversocket,他回自己建立管理线程的
 
这是d5的帮助,看3,4,5,6,7
1,An OnListen event occurs just before the server socket is opened for
listening.
2,The server socket receives client requests in a listening queue.
The server socket accepts one of those requests, and receives a Windows socket
handle for the new socket connection.
3,The server socket generates an OnGetSocket event, passing in the Windows
socket handle. If a TServerClientWinSocket object for the server endpoint
of the new connection is not created in an OnGetSocket event handler, the
server socket creates one. The TServerWinSocket object continues to listen
for other clients.
4,An OnAccept event occurs, using the new TServerClientWinSocket object.
5,If ServerType is stThreadBlocking and no thread is available in the cache,
an OnGetThread event occurs. If the OnGetThread event handlerdo
es not create
a thread, the server socket creates a TServerClientThread.
6,If ServerType is stThreadBlocking, an OnThreadStart event occurs as the
thread begin
s execution.
7,The client completes the connection to the TServerClientWinSocket
object and an OnClientConnect event occurs.
 
完全可以。ICS控件中的FTP控件对多线程支持得比较好。
你可以用它来做,只需要再继承一个TThread即可。
 
大家分了吧!
 
顶部