Re: Emulating I/O Completion Port on Win98.
From: Alexander Nickolov (agnickolov_at_mvps.org)
Date: 12/06/04
- Next message: Eugene Gershnik: "Re: De-/Activate protocol/service for network adapters"
- Previous message: Eugene Gershnik: "Re: WinSock TCP Buffer Status"
- Maybe in reply to: Arkady Frenkel: "Re: Emulating I/O Completion Port on Win98."
- Next in thread: Arkady Frenkel: "Re: Emulating I/O Completion Port on Win98."
- Reply: Arkady Frenkel: "Re: Emulating I/O Completion Port on Win98."
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 6 Dec 2004 10:39:23 -0800
Either create a separate thread, use non-blocking I/O (select,
WSAEventSelect), or for GUI programs - use async I/O
via Windows messages - WSAAsyncSelect. Overlapped
I/O is also fine, though it has no benefits on Win9x as the
kernel does not support it so it's done entirely in user mode.
-- ===================================== Alexander Nickolov Microsoft MVP [VC], MCSD email: agnickolov@mvps.org MVP VC FAQ: http://www.mvps.org/vcfaq ===================================== "Sami" <s8a2m9i1_i5s1l9a6m@hotmail.com> wrote in message news:uy24EY52EHA.3616@TK2MSFTNGP11.phx.gbl... > Hello Arkady, > > My Client is an FTP Client and I thought emulating IOCP would be the best > solution under Win98 to quickly copy a big file from the FTP Server. > > What is actually the normal way to receive a big file without blocking the > client program throughtout the whole time it takes to copy the file from > the > server? > > If I just do a WSARecv( ) in a loop till I get the number of bytes of the > big file then everything else would block. > -- > Regards, > Sami > > [Remove Numbers from e-mail address to use it] > "Arkady Frenkel" <arkadyf@hotmailxdotxcom> schrieb im Newsbeitrag > news:OEdLWKV2EHA.3408@tk2msftngp13.phx.gbl... >> 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: Eugene Gershnik: "Re: De-/Activate protocol/service for network adapters"
- Previous message: Eugene Gershnik: "Re: WinSock TCP Buffer Status"
- Maybe in reply to: Arkady Frenkel: "Re: Emulating I/O Completion Port on Win98."
- Next in thread: Arkady Frenkel: "Re: Emulating I/O Completion Port on Win98."
- Reply: Arkady Frenkel: "Re: Emulating I/O Completion Port on Win98."
- Messages sorted by: [ date ] [ thread ]