lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



    In function pRead of libhttpd.c:

----
    n = read(sockfd,buffer,sizeof(buffer)-1);


    lua_pushnumber(L, n );
    lua_pushstring(L, buffer );

  A more interesting question is what to do if the data read contains
 NULLs.  So far that hasn't been a problem, but I'm not sure without
 checking whether Lua strings are NULL-clean..

Lua strings may contain 0x00 characters.

One way to improve the code returning the result would be to simply replace it with:

	lua_pushlstring(L, buffer, n);

This would get you on your way to enable sending images, for instance [something the current approach won't handle...].

You might want the check return value from the read() call as well.

Ashwin.
--
no signature is a signature.