<b class="gmail_sendername"></b><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">> 2)I suppose socket_internal_iocp_read is called before you invoke the
<br>> callback to let the callback consume the received data. Why do you call<br>> socket_internal_iocp_read firstly?<br><br>Well, socket_internal_iocp_read() issues a non-blocking ReadEx() on the<br>socket. The user could do this, but the API can do it for him without
<br>any loss of functionality. So, when the user gives me a socket, I issue<br>a read on it; then, when the read completes, I call the callback to pass<br>him the data and issue another read. This way, it's simpler and easier
<br>for the user; all he does is add his socket, and then that's it - the<br>callback is called when data arrives. He has nothing else to worry<br>about or so.</blockquote><div><br><br>I have made some mistake when I type the above words. I just mean you should issue socket_internal_iocp_read firstly and then let the callbacks to consume the data. However, in your code, you invoke the callbacks before socket_internal_iocp_read. See the following snippet:
<br> siss->callback_function( siss->socket, SOCKET_IOCP_SOCKET_RECV_SUCCESS, siss->read_buffer, byte_count, (void *) siss->user_state );<br> socket_internal_iocp_read( siss );<br><br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> 3)Is there any plan to support all of the Async operations, such as<br>> connect, listen, accept, read and write?<br><br>I added listen and accept last week, and I'm testing them now. I didn't<br>add connect, because ConnectEx() is XP and higher only (it's not
<br>available under w2k). I've not added support for writes, because I<br>think people generally issue blocking writes, since non-blocking means<br>that if you return from a function which issues a send you have to<br>ensure the lifetime of the buffer you've sent is non-local.
</blockquote><div><br>As others have pointed out, Async WRITE is important for high-performance server. <br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Single-thread event-driven seems to me to basically mean state machine.<br> State machines are wonderful things for achieving simple, bug-free<br>code, but they have a cost; they are implicitly single-threaded. This<br>
can mean you cannot use them in some situations, because you will<br>inherently block whenever you perform work.<br><br>Also note that with GetQueuedCompletionStatus(), you're supposed, for<br>optimal performance, to have multiple threads (2xCPU) blocking on the
<br>IOCP object.<br><br>Given the advent and growing popularity of multi-core CPUs, single<br>threaded blocking seems inappropriate.<br><br>Note though that with GetQueuedCompletionStatus(), the user has no<br>synchronization work to do. The API handles it all behind the scenes.
</blockquote><div><br>Single-thread event-driven model just means the event loop is running in one thread's context. There a lot of ways to combine it with the multi-thread worker.<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
_______________________________________________<br>Libevent-users mailing list<br><a href="mailto:Libevent-users@monkey.org">Libevent-users@monkey.org</a><br><a href="http://monkey.org/mailman/listinfo/libevent-users">http://monkey.org/mailman/listinfo/libevent-users
</a><br></blockquote></div><br>