[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua and networking - possibly basic question
- From: "Ashwin Hirschi" <deery@...>
- Date: Sat, 29 Oct 2005 21:24:05 +0200
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.
no signature is a signature.