 |
|
 |
hi again (!)
If I refresh countinuosly my webpage my ARM system throws an ADDR_ABORT exception, probably due to recursion (but my stacks seem healty...) Any suggestion on how to avoid recursion on wi_readfile ?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Perhaps I've found the solution (memory leak). wi_alloc needs a check on malloc success:
wi_alloc(int bufsize) { char * buffer; struct memmarker * mark; int totalsize;
totalsize = bufsize + sizeof(struct memmarker) + 4;
buffer = WI_MALLOC(totalsize); if (buffer == 0) // PB 03/07/2009 17.58.07 return (0); // PB 03/07/2009 17.58.12 ...................
Hope this will help somebody
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
This is definitely a bug. I'd better review the code for making sure I check all results of malloc. Thanks for pointing this out. -JB-
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, I am porting your webserver to an ARM processor. I woud need to upload my files (with curl) and wi_putfile seem perfect - but it's empty... Did you put some work on this routine ? Any suggestion should I implement it by myself ?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, very good work. How about adding AJAX support for dynamic refresh of portions of page ? I've already done some work on this, maybe we can cooperate....
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I thought AJAX was mostly client side. As such it should "just work" with Webio. Are there any specific features that are needed? -JB-
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
yes, you are right, it's almost client side. I was thinking to automate some functions (like XMLHttpRequest creation and handling) via fsbuilder, who creates callback stubs already....
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Several users have quite rightly pointed out that I forgot the Linux makefile. A Makefile for Linux is now available at the link below. I've tested it building the code base down-loadable from this page on Fedora 7. Let me know if it works (or not) with other code bases and Linux versions.
Here's the link:
http://www.praemio.com/webio/makefile
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Code works fine in Windows, but how to compile in Linux? There is no make file included! The explanation of compiling in Linux is quite short and I can't follow... 
regards
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi - sorry about forgetting the Linux makefile. I think the easiest way to provide one is to paste it directly into this message. Just copy into a local file, delete these leading lines, and make. Hope this works.... #=================================================== #-------------------------------------------------------------------------------
# Makefile for webio - Linux demo app
#
# The code files (object names) for webio.
WEBIO_OBJS = webclib.o webfs.o webio.o webobjs.o \
websys.o webutils.o webtest.o
# The Content-containing C files produced by fsbuilder CONTENT_C = wsfdata.c wsfcode.c
# Object versions of the content-containing C files CONTENT_OBJS = wsfdata.o
# The Ultimate Target of this makefile
WEBIO = webio
# File system builder utility to convert content into C files FSBUILDER = fsbuilder
# C flags. If you forget the -DLINUX it will try to build a windows version CC_FLAGS = -c -DLINUX
.c.o:
$(CC) $(CC_FLAGS) $*.c
# Build the actual server. This links both the code files (WEBIO_OBJS) and # some embedded content $(CONTENT_OBJS) $(WEBIO): $(WEBIO_OBJS) $(CONTENT_OBJS) gcc $(WEBIO_OBJS) $(CONTENT_OBJS)
# Build C files containing content. $(CONTENT_C): $(FSBUILDER) filelist ./fsbuilder filelist
# Make the fsbuilder utillity. This is required for this example. webio apps # with no embedded content (i.e. content is all regular disk files) don't # need fsbuilder $(FSBUILDER): fsbuilder.cpp g++ -o fsbuilder fsbuilder.cpp
clean:
rm -f *.o rm -f $(CONTENT_C)
rm -f webio
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi, I recently discover the embedded server, and I find it great.
In my case, I have to return image whose the name is dynamically generated. In my use case, the user retrieves an XML file containing the image names. From these names he can retrieve the images. As the XML contains data about the images, and they are always changing, the unique name is useful to be sure the images are properly matching the XML. So to summarize I have: http://localhost/data.xml containing
<foo> <image="12345.jpg" x=7 y=5 /> <image="12346.jpg" x=7 y=6 /> </foo>
I need to provide http://localhost/12345.jpg and http://localhost/123456.jpg As these names are always changing, they can not come from the fsbuilder.
If I'm correct it's not possible with the current webio version. Is it true ? To do it, I was thinking to add a new filesystems in the wi_filesys table, allowing pure dynamic recording of file. Is it the right way to do it ?
Thanks
Arno
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Would ravenspoint be willing to share this cWebIo class that he/she talks about below ? We would greatly appreciate the pointer.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi Folks, Release 1.3. is ready. Source download is available here:
http://www.praemio.com/webio/webio1_3.zip http://www.praemio.com/webio/progman.html
I'm working on getting this site updated (author's can't edit their own projects )
The main additions Are:
- A new feature in fsbuilder which allows it to build form code form a scanned HTML page, but without including the HTML page in the embedded file set. This is useful for folks who want the page containing the form on disk, but also want to take advantage of fsbuilder code generation.
- A feature to spawn a new thread to process each CCGI routine. This allows time consuming CGI functons to execute with blocking the core processing thread. This is currently in the windows port - Linux support will come soon.
And threee bugs were fixed:
* fsbuilder now replaces spaces in form control names with underscore when generating C language names. * fsbuilder bug fixed: It crashed if form name was omitted after "-f" option * Fixed webio authentication bug when receiving large http headers. Symptom was authentication just failed when it should have passed.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
For supersimple web applications, developing your own C++ embedded web server is OK but if you need to do something "real", which needs scalability, ease of development (no need to write HTML, CSS or Javascript), multithread, etc, use Wt (there are packages available for Debian and Ubuntu under the name witty)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Firstly, great article, and great project. Well written up - clearly something that has been evolved over time (if not in code, then in concept), and clearly a topic the author knows well.
For many projects will be able embed a http server using webio as-is.
But I have some code using boost::asio for network servers, and I don't want to add a separate thread and a new library to enable http. However, I'd like to leverage webio within the boost::asio code that I have.
It seems to me the ideal would be using boost::asio for the network management, webio for aspects of url management and file embedding, and some django-style glue code for mapping urls to files or to embedded data or to function calls.
For example:
main() { // simplified ... http_server http(8080); http.map_url("/media(.*)$", media_url_mapper("./rawfiles")); http.map_url("/res(.*)$", embed_resource_mapper()); http.map_url("/stat", boost::bind(do_stat_function)); io_service.run(); }
I know this is a bit off topic, but WDYT?
Thanks again for a great article and the excellent webio library and embedding tool/resource compiler.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi J,
i'm unable to link your project i always get the following error [Linker Error] undefined reference to `WI_NOBLOCKSOCK'
can you help me.
thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
The WI_NOBLOCKSOCK() macro is supposed to set a socket into non-blocking mode. Since this is different between Windows and Linux, it's ifdeffed based on OS.
If you are building for windows it should be a function in the file websys.c. The complete source is:
#ifdef _WINSOCKAPI_ int WI_NOBLOCKSOCK(long sock) { int err; int option = TRUE;
err = ioctlsocket((int)sock, FIONBIO, (u_long *)&option); return(err); }
The easiest way to get this on windows is probably to include websys.c in your build; if you can't do that then use the source above.
If you're not building for windows, let me know what your target OS is.
Hope this helps,
-JB-
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi J,
thanks, it works now. just for your information i compiled it for Windows Vista on MinGw. anyway, many thanks.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I'm looking for a good embedded web server day by day, and today i find webio. I haven't try it now, wish it will lead a great world to me. thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
The procedure for displaying dynamic content in a webpage using webio is quite complex. Unfortunately, the explanation in progman.html makes it seem harder than it really is. Here is a simple recipe to get you started.
- Choose a unique identifier for the string to be displayed. Let's call it XYZ.
- Create a method that returns a pointer to a buffer containing the string to be displayed. Something like this
static char * cMyClass::getDisplayStringXYZ();
- Add html to place the string where you want it in the web page. Something like this
Display Sting XYZ goes just here: <!--#include file="XYZ" -->
- Add a line to the file "filelist" like this
XYZ -e u_long x ( The "u_long x" does not have any significance, but must be there anyhow )
- Run this command
fsbuilder -g wsfcode.c filelist
- Open wsfcode.c and find the identifier XYZ. It will be followed by a number. Let's say 43.
- If it does not already exist, create a C routine called wi_cvariables in the global namespace. This is NOT a C++ routine. Something like this
#include "MyClass.h"
extern "C" { int wi_cvariables(wi_sess * sess, int token) { switch(token) { } return 0; } }
- Add code to the switch statement like this
case 43: wi_printf( sess, cMyClass::getDisplayStringXYZ() ); break;
- Rebuild your application.
It is a lot of steps, some of them quite mysterious. Just do it a couple times, then re-read the explanation in progman.html. It should be easier to understand now, and will give you lots of suggestions for modifying the recipe.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
A simple, one line change to webio has allowed me to simplify the recipe for displaying dynamic content. You no longer need to muck about with BOTH a string identifier and a string token. ( The token is not only unnecessary, but liable to change from time to time, which I would consider a bug ) Here is the recipe first:
- Choose a unique identifier for the string to be displayed. Let's call it XYZ.
- Create a function that returns a pointer to a buffer containing the string to be displayed. Unfortunately, this has to be a function in the global namespace, because I do not know how to store pointer to member functions. Something like this
char * getDisplayStringXYZ();
- Add html to place the string where you want it in the web page. Something like this
Display Sting XYZ goes just here: <!--#include file="XYZ" -->
- Add a line to the file "filelist" like this
XYZ -e u_long x
( The "u_long x" does not have any significance, but must be there anyhow )
- Run this command
fsbuilder -g wsfcode.c filelist
- Add code like this, before you start the server
cWebio::SetLink( "XYZ", &getDisplayStringXYZ );
- Rebuild your application.
-------------------------------------
The trick to achieving this is to change the call to wi_cvariables ( line 639, webutils.c ) to
error = wi_cvariables(sess, ssifname );
Now wi_cvariables can be implemented as a one line routine that need never be changed
int wi_cvariables(wi_sess * sess, char * idname) { return cWebio::ResolveLink( sess, idname ); }
cWebio is needed to make this work, of course, because it maintains a private map of idnames to function pointers.
----------------------------------------
I would really like to avoid using filelist altogether. However, I cannot immediatly see how to manage this. The issue seems to be that without running fsbuilder with the string identifier specified in filelist, line 729 in webio.c is not executed. Perhaps John Bartas could explain this mystery to me?
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
ravenspoint wrote: The issue seems to be that without running fsbuilder with the string identifier specified in filelist, line 729 in webio.c is not executed. Perhaps John Bartas could explain this mystery to me?
Found it! If the filename does not contain a dot, and is not mentioned in filelist, it is assumed to be binary. ( line 535, webutils.c )
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |