Re: Emulating I/O Completion Port on Win98.
From: Arkady Frenkel (arkadyf_at_hotmailxdotxcom)
Date: 12/03/04
- Next message: Arkady Frenkel: "Re: is there a ready design to determine message bounds in stream?"
- Previous message: Arkady Frenkel: "Re: Dead Gateway Detection"
- Next in thread: Alexander Nickolov: "Re: Emulating I/O Completion Port on Win98."
- Maybe reply: Alexander Nickolov: "Re: Emulating I/O Completion Port on Win98."
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 3 Dec 2004 18:07:28 +0200
Sami !
Why you need IOCP on Client , usually that model is scalable solution for
server , not client ?
If you client behave as a server to other client you do can use IOCP too ,
but not in the relation with server.
Any case look inside...
"Sami" <s8a2m9i1_i5s1l9a6m@hotmail.com> wrote in message
news:eAdCoz71EHA.3408@tk2msftngp13.phx.gbl...
> Hello,
> I would like to emulate I/O Completion ports on Win98.
> My program is a TCP Client (FTP Client to be more exact) that listens
> passively on one port. After the server send a file into the listening
> socket I would like to apply an I/O Completion port architecture (on the
> Client) to handle the downloading of file from FTP Server to the FTP
Client.
>
> Here is a pseudo-code that I have from this newsgroup from along time
ago.
> ++++++++++++++++++++++++++++++++++++++++++++++++++++
> CIOComplete
> {
> typedef struct
> {
> HANDLE hThread; // handle to worker thread;
> MySock * sock; // the socket need worker thread to handle
> HANDLE hEvent; // Used to inform the worker thread there is operation
> need to be performed
> } SOCKWORKER;
> typedef struct
> {
> SOKCET socket;
> OVERLAPPED * overlap;
> } MyS***;
> CList<SOCKWORKER> m_list; // worker threads
> CList<MySock> m_listSockets; // a list of sockets
> BOOL AddSock (MySock sock);
> }
>
> This class works like the following way:
>
> Several worker threads are spawned and wait on the hEvent. There is a
> monitor thread created dedicates to check the IO status of the sockets in
> m_listSockets. If there is a socket that has read or write operation
> performed. The monitor thread will select an idle worker thread and fill
in
> sock and dOperation, then the monitor thread set the hEvent to active the
> worker thread to handle the socket. After finishing the work, the worker
> thread will mark sock to zero to indicates it's idle and wait on hEvent
> again.
>
> DWORD WorkerThread (void * ptr)
> {
> SOCKWORKER * worker = ptr;
>
> while (WaitForSingleObject(worker->hEvent, INFINITE) == WAIT_OBJECT_0)
> {
> If (worker->sock)
> {
> // perform the work
> } worker->sock = 0;
> } return 0;
> }
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> My questions:
> 1) How many sockets should be in the list?
In IOCP model the number of sockets is the number of connections and model
desire is to limit number of threads threating those sockets like only 2
threads threat few thousands of sockets
> 2) Am I correct in thinking that my main( ) is going to create the list of
> sockets? Or do I need a separate thread to create the list and maintain
it?
Seems OK
> 3) If my TCP Client is listening on one socket (and that is how I want it
to
> be as it is an FTP Client) should I just forward whatever comes into the
> listening socket to one of the sockets in the list and then flag the
worker
> thread to take over?
That's why I ask you why you need IOCP where huge number of sockets treated
by few threads.
In your case working thread can connect and treat this socket
Arkady
>
> --
> Regards,
> Sami
>
> [Remove Numbers from e-mail address to use it]
>
>
- Next message: Arkady Frenkel: "Re: is there a ready design to determine message bounds in stream?"
- Previous message: Arkady Frenkel: "Re: Dead Gateway Detection"
- Next in thread: Alexander Nickolov: "Re: Emulating I/O Completion Port on Win98."
- Maybe reply: Alexander Nickolov: "Re: Emulating I/O Completion Port on Win98."
- Messages sorted by: [ date ] [ thread ]