From: Steve K. <ha...@ya...> - 2006-08-01 22:02:32
|
Hi everyone, I have problem when using wxSocket in wxLua, ReadMsg return some garbage at the end of the string. The senario is: c. WriteMsg(luastr, luastr:len()) s. ReadMsg(80) // 80 is assured to be much bigger than luastr:len() If using in C++ (wxWidgets) the buffer returned by ReadMsg (even the nbytes is much bigger than the len actually written to socket) is the correct len. Have looked at the wxWidget source code and verify this. However if using it in Lua, I get garbage string at the end. So I propose to change this line: lua_pushlstring(L, (const char *)buffer, nbytes); to lua_pushlstring(L, (const char *)buffer, self->LastCount()); // skieu in wxLua_wxSocketBase_Read(lua_State *L) and wxLua_wxSocketBase_ReadMsg(lua_State *L) I am not sure of the side effect of that change but it worked for me, I never get any garbage since then :-) Any comment? Cheers S.KIEU Send instant messages to your online friends http://au.messenger.yahoo.com |