Home » U++ Library support » U++ MT-multithreading and servers » SocketEvent
SocketEvent [message #10214] |
Mon, 25 June 2007 14:02 |
zaurus
Messages: 42 Registered: May 2006
|
Member |
|
|
Hi!
I found the SocketEvent class in socket.h, but don't really understand how it can be used. So far it looks to me that I can activate to get some kind of event in case there is a new connection on the server socket or if data arrives.
Anybody has some tips or a small example how to make use of this events?
Thanks for any hints.
|
|
|
|
Re: SocketEvent [message #13572 is a reply to message #10214] |
Tue, 15 January 2008 08:56 |
rylek
Messages: 79 Registered: November 2005
|
Member |
|
|
Hi there!
The trouble is, that instead of Unix / Linux, where the sockets are a built-in component of the OS and the file system, in Windows they are more like a hack glued to the OS by a few bits of adhesive tape. One of the implications of this is that you cannot mix socket and file handles, which you can freely do under Linux, another is that a socket handle, instead of a file handle, is not a valid object handle in the Windows sense to wait upon. So, wherever you need to do a
WaitForSingleObject
or a
MsgWaitForMultipleObjects
which includes a socket (typically in a web-enabled single-threaded GUI application you need to listen to sockets and check the message queue at the same time), you must create a proxy event. This is exactly what SocketEvent is for: you tell it to connect to a socket observing a certain socket action (or a combination thereof) and its event handle (inherited from the SyncObject class) can be then used in calls to the Wait functions. The WaitForSingleObject can be called via the SyncObject::Wait method. However, the multiple wait currently has no "elegant" wrapper in U++, you have to call it by yourself. I'll try to make for you a simple elegant example, the only real-life example I have is neither simple nor elegant and is not very likely to shed much light on this for you.
Regards
Tomas
|
|
|
|
|
Goto Forum:
Current Time: Fri Mar 29 05:44:30 CET 2024
Total time taken to generate the page: 0.01097 seconds
|