Home » Developing U++ » U++ Developers corner » Socket review and reimplementation
Socket review and reimplementation [message #8819] |
Mon, 02 April 2007 14:37 |
fallingdutch
Messages: 258 Registered: July 2006
|
Experienced Member |
|
|
At the moment i am having a look at the current implementation of Sockets in Ultimate++.
I am thinking of rewriting the Sockets but not without asking you about your ideas.
I have talked to Tom and Mirek and the current plan looks like this:
a basic socket class with minimal function, derived classes like TcpSocket and UdpSocket with extended functionality.
When using CtrlCore (Gui Applications) Ultimate++ can handle (if wished) receiving and sending of data and will call a callback when data arrived or when data was sent.
So you won't have to take care about select or WaitForMultipleObject yourself.
There are also thought about adding Sockets to Core.
Any Ideas are very welcome
Bas
[Updated on: Mon, 02 April 2007 14:45] Report message to a moderator
|
|
|
Re: Socket review and reimplementation [message #8820 is a reply to message #8819] |
Mon, 02 April 2007 14:45 |
|
mirek
Messages: 14036 Registered: November 2005
|
Ultimate Member |
|
|
On related note, there is quite a lot going on with Core now...
As Core grows, I consider dividing it into two packages, "HardCore" and "Core", former intended for lower-level stuff and OS encapsulation (Streams, Heap, String etc...), later for higher-level (Date/Time, Value, Callbacks).
Mirek
|
|
|
|
|
|
Re: Socket review and reimplementation [message #8838 is a reply to message #8835] |
Mon, 02 April 2007 22:53 |
fallingdutch
Messages: 258 Registered: July 2006
|
Experienced Member |
|
|
zsolt wrote on Mon, 02 April 2007 21:23 | This is a good idea.
Before you start implementation, you should check libevent, I think. It provides a transparent API to poll(), select() and event based APIs of different platforms, such as epoll, kqueue, etc. Using select() is very archaic on some unixes. These kernel services are much powerful compared to the old select().
libevent is BSD licensed, very stable and very easy to use.
|
Thank you for that link, browsing on it at the moment.
Correct me if i am wrong, but Ultimate++ uses in its main loop MsgWaitOnMultipleObjects for windows and select for linux (to listen on the socket for incomming X11 events) so this Wait/Select will be used for the sockets to wait for an event, too.
Bas
|
|
|
|
Re: Socket review and reimplementation [message #9250 is a reply to message #9247] |
Mon, 23 April 2007 23:11 |
zsolt
Messages: 698 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
Thanks for working on that.
May I suggest to implement the loop using some pluggable interfaces?
I mean, that in some situations (e.g. web servers), a fully featured mainloop is not needed, but performance is much more important. An other aspect is, that Unixes don't have a generic event handling interface, that can be used for every type of events, like MsgWaitForMultipleObjects on Windows.
I would prefer an extensible API, usable like this or something similar:
MainLoop<StdLoop> mainloop;
or
MainLoop<LibeventLoop> mainloop;
For simple TCP servers on unixes, using libevent as an option some way would be a killer solution because of it's performance.
|
|
|
|
Re: Socket review and reimplementation [message #9253 is a reply to message #8819] |
Tue, 24 April 2007 03:04 |
lundman
Messages: 175 Registered: March 2006 Location: Tokyo
|
Experienced Member |
|
|
Having written my own network/event/ssl library, there are some finer things to be aware of, but no-show-stoppers.
Using select() is fine, even under windows, but be aware that Windows don't like an empty select() call. Using poll() instead, if it exists is trivial.
Non-blocking was fine, but socketpair do not work in Windows, had to use a localhost-tcp connection (same for NetBSD in non-blocking mode). Non-blocking files in Windows are tricky, if you want to be compatible with all of the versions of Windows. The only way I could see to do it, using one code base, was to start read/write threads. (I dislike using threads, but 95/98/Me did not support any ASync calls, and I wanted to support all versions of Windows, at the time).
Anyway, when it comes to Networking, and SSL, I consider myself to be close to an expert, but alas, complete newbie when it comes to U++
All sources etc are available for peekage:
http://www.lundman.net/wiki/index.php/LiON
Sample code:
http://www.lundman.net/unix/lion-example.c
|
|
|
|
|
|
Goto Forum:
Current Time: Thu Sep 19 08:31:44 CEST 2024
Total time taken to generate the page: 0.02283 seconds
|