Sample: Chat

Topics: Samples and Patterns
Jan 10, 2007 at 7:03 AM
Added sample to the source tree called PcrChat. It simulates a network chat group using PCR as the local "network". It demos some of the power of the library. Can start multiple clients and all clients see all messages from other clients using a tiny shared server object as the proxy. Basically, each client has a reply port for new messages and the server has a InPort for new messages from any client. The server then broadcasts new messages to all clients. In just over 250 lines of code (most of it GUI code), it is a pretty neat little sample.

Jul 12, 2007 at 5:03 AM
That is pretty neat, and it's close to what I'm trying to get to. But what if I want each client only to receive it's own messages... how would I sequence this, do I just use the shared storage like this and have them all filter for a key... that might be a little too chatty for something like a data engine. I just can't get my head around how I'd be able to take advantage of asynch operations in a client server scenario, though it all makes complete sense when you're printing stuff to the console and broadcasting, I'm just missing the last piece. I'm sure I'm not the only one. Can you please enlighten?
Jul 13, 2007 at 4:29 AM
sorry to post again, but someone actually articulated the issue very well on a news group about IOCP... nobody shows any examples of actually writing data back to a client. which is the bit I'm a little frustrated with. Not to do with your library in particular, but it's a screwey scenario in basically all situations that would use IOCP. I think Winsock accounts for this by offering AcceptEx with the native call, but as far as I can see there isn't an equivalent nice (not that AcceptEx makes it all that much clearer) way to do this in the CLR because it's such a new idea, and basically doing this in managed code virtualizes the whole process so the native implementation may not only be painful, but actually counter productive, exposing one to the preemptive nature of the native IOCP stuff. Does that help make what I'm getting at any clearer? I hope so.