News for hackers. Stuff that matters.
Re:Show HN: My embeddable C/C++ webserver by udp on Friday May 06, 2011 @09:41AM (#2520883)
This webserver is the most complete part of a high-level, cross-platform networking library I've been working on. The rest of the examples: https://github.com/udp/lacewing/tree/master/examples

ajax.cc is probably the most interesting - it's an example of long-poll AJAX with jQuery and Lacewing::Webserver as a backend. Lacewing uses epoll/kqueue/IOCP rather than a traditional select/poll approach, so it should scale quite well.

I've been developing Lacewing pretty much in private for quite a while, now - it's quite daunting when I start thinking about having to write all the documentation and such, but this morning I just thought "screw it, it's going on github, undocumented or not". It might as well be public while I'm getting it all together...

Re:Show HN: My embeddable C/C++ webserver by mellery451 on Friday May 06, 2011 @12:16PM (#2521374)
Thanks for sharing. How does the basic functionality compare with, say, http://www.gnu.org/software/libmicrohttpd/ or http://cpp-netlib.github.com/ ? (the latter looks like it might eventually be incorporated in boost).
Re:Show HN: My embeddable C/C++ webserver by munificent on Friday May 06, 2011 @11:26AM (#2521187)
Wow. Your code is a joy to read. Really clean and well-laid-out.
Re:Show HN: My embeddable C/C++ webserver by udp on Friday May 06, 2011 @11:33AM (#2521216)
Thanks, that's really nice to hear! :-)

Some parts need improving, mainly because of how long I've been working on it - there were many gaps in my knowledge when I started. I don't think I've learnt so much from any project!

Re:Show HN: My embeddable C/C++ webserver by dkersten on Friday May 06, 2011 @10:12AM (#2520960)
Thanks for sharing! I was actually looking for a lightweight embeddable C/C++ web server not long ago, perhaps this will fit my needs. Only thing I'm wondering about is does it (or will it in the future) have windows and mac support? Ideally I am looking for something cross platform for what I have in mind.

(My current solution is JVM based (over JNI) and uses Jetty, but I really want to eliminate the JVM dependency - I use it for more than just the web server, but the other stuff is easy enough to replace with C++ solutions)

Re:Show HN: My embeddable C/C++ webserver by udp on Friday May 06, 2011 @10:14AM (#2520971)
Yes, I've used it on both Windows and OS X, as well as Linux and FreeBSD servers.

It uses IOCP on Windows and kqueue on OS X. There's a project file in the 'msvc' folder which should build out of the box on Windows - on OS X you probably need macports with autoconf/automake/libtool to build it.

Re:Show HN: My embeddable C/C++ webserver by dkersten on Friday May 06, 2011 @10:19AM (#2520983)
Awesome! Thanks! I will definitely dig into this more over the coming days.
Re:Show HN: My embeddable C/C++ webserver by luckystrike on Friday May 06, 2011 @01:23PM (#2521660)
You can also check out libebb - http://tinyclouds.org/libebb/
Re:Show HN: My embeddable C/C++ webserver by dkersten on Friday May 06, 2011 @03:52PM (#2522226)
Thanks for the suggestion, I'll check it out.
Re:Show HN: My embeddable C/C++ webserver by Yoric on Friday May 06, 2011 @10:01AM (#2520930)
Interesting. Is there a specific purpose to this webserver?
Re:Show HN: My embeddable C/C++ webserver by udp on Friday May 06, 2011 @10:04AM (#2520939)
I suppose it's just meant to be easily embeddable into just about anything. It could be used to add webserver functionality into an existing application (think web control interface for a daemon), or it could even be used to write a complete C/C++ web-application or backend.

I don't want to make any claims about the performance of Lacewing (aside from anything else, it's too early for that) but one would assume a backend written in C/C++ would be a little faster than one written in a scripting language. Although probably quite a pain to write..!

From a technical point of view, I found that most webservers were tuned for high performance on Unix, but on Windows they wouldn't run very well at all. The news earlier about Node.js having Windows support on the roadmap (which is mainly what prompted me to release Lacewing today) suggests that it's worth supporting, and Lacewing has used IOCP and other tricks on Windows from day one.

Re:Show HN: My embeddable C/C++ webserver by jason_slack on Friday May 06, 2011 @11:19AM (#2521160)
what about embedding in an iOS app? Any thoughts on this and if Apple will let is pass?
Re:Show HN: My embeddable C/C++ webserver by udp on Friday May 06, 2011 @11:34AM (#2521224)
It would certainly be interesting to try - do you know if kqueue is available on iOS? If not, I guess the only thing to do would be writing a select() or poll() fallback for the EventPump class. I might have a look at it sometime.

Having said that, I'm not sure how much use the server stuff would be on iOS, and I haven't yet written the Unix implementation of the Client class (not that that will be very much work).

Re:Show HN: My embeddable C/C++ webserver by tptacek on Friday May 06, 2011 @12:11PM (#2521350)
Yes, iOS has working kqueue.

I have some reason to believe you can get libevent working on iOS with minimal drama; I think there's at least one app that embeds it.

Which, by the way, is what I would suggest you do with your code; if you're so dependent on kqueue that it's a portability issue, you have little to lose and lots to gain by ditching the custom event loop.

Re:Show HN: My embeddable C/C++ webserver by udp on Friday May 06, 2011 @01:00PM (#2521570)
I support epoll and IOCP, too, and I don't consider event handling something complicated enough to justify bringing in an external library.

I quite value the freedom of dependencies Lacewing currently has (except the obvious OpenSSL, etc - although it doesn't use OpenSSL on Windows, it uses native Windows SSL).

Re:Show HN: My embeddable C/C++ webserver by tptacek on Friday May 06, 2011 @01:09PM (#2521602)
libevent is small enough to simply bake in and embed, which is what I usually do, but if you like your own event library that's fine.
Re:Show HN: My embeddable C/C++ webserver by benologist on Friday May 06, 2011 @10:27PM (#2523086)
I downloaded an app that seems to embed an FTP server in itself (comicbook lover), if that passes muster then HTTP might be OK?
Re:Show HN: My embeddable C/C++ webserver by jasonlotito on Friday May 06, 2011 @11:51AM (#2521284)
Good Reader seems to use a web server to allow you to upload documents, so I don't think this is an issue.