Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » SocketEvent
SocketEvent [message #10214] Mon, 25 June 2007 14:02 Go to next message
zaurus is currently offline  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 #13540 is a reply to message #10214] Mon, 14 January 2008 15:15 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
I too would like to know this.

--bump--
Re: SocketEvent [message #13572 is a reply to message #10214] Tue, 15 January 2008 08:56 Go to previous messageGo to next message
rylek is currently offline  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
Re: SocketEvent [message #13580 is a reply to message #13572] Tue, 15 January 2008 14:21 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
rylek, thanks for the explanation, it makes much sense. I look forward to the example.

Re: SocketEvent [message #13592 is a reply to message #13572] Wed, 16 January 2008 02:55 Go to previous message
bonami is currently offline  bonami
Messages: 186
Registered: June 2007
Location: Beijing
Experienced Member
did not see carefully what U R talking about. donno whether WSAEventSelect is relevant to this.
Previous Topic: Thread based "conveyor" class for Win32
Next Topic: Socket functions calling order
Goto Forum:
  


Current Time: Thu Mar 28 19:03:02 CET 2024

Total time taken to generate the page: 0.01269 seconds