diff --git a/luasocket.sln b/luasocket.sln index 11d7824..6a1d0b8 100644 --- a/luasocket.sln +++ b/luasocket.sln @@ -7,10 +7,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mime", "mime.vcproj", "{128 ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "smtp", "smtp.vcproj", "{128E8BD0-174A-48F0-8771-92B1E8D18713}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug @@ -25,10 +21,6 @@ Global {128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug.Build.0 = Debug|Win32 {128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.ActiveCfg = Release|Win32 {128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.Build.0 = Release|Win32 - {128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug.ActiveCfg = Debug|Win32 - {128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug.Build.0 = Debug|Win32 - {128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.ActiveCfg = Release|Win32 - {128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection diff --git a/samples/talker.lua b/samples/talker.lua index 94d2133..bafd021 100644 --- a/samples/talker.lua +++ b/samples/talker.lua @@ -4,7 +4,7 @@ -- Author: Diego Nehab -- RCS ID: $Id$ ----------------------------------------------------------------------------- -require("socket") +socket = require("socket") host = host or "localhost" port = port or 8080 if arg then diff --git a/src/buffer.c b/src/buffer.c index fd885a2..60e42ae 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -66,8 +66,16 @@ int buf_meth_send(lua_State *L, p_buf buf) err = sendraw(buf, data, count, &sent); total += sent; } - lua_pushnumber(L, total); - io_pusherror(L, err); + /* check if there was an error */ + if (err != IO_DONE) { + lua_pushnil(L); + io_pusherror(L, err); + lua_pushnumber(L, total); + } else { + lua_pushnumber(L, total); + lua_pushnil(L); + lua_pushnil(L); + } #ifdef LUASOCKET_DEBUG /* push time elapsed during operation as the last return value */ lua_pushnumber(L, (tm_gettime() - tm_getstart(tm))/1000.0); diff --git a/test/testclnt.lua b/test/testclnt.lua index da6b2e8..b295cf3 100644 --- a/test/testclnt.lua +++ b/test/testclnt.lua @@ -225,7 +225,7 @@ function test_totaltimeoutsend(len, tm, sl) ]], 2*tm, len, sl, sl, len)) data:settimeout(tm, "total") str = string.rep("a", 2*len) - total, err, elapsed = data:send(str) + total, err, partial, elapsed = data:send(str) check_timeout(tm, sl, elapsed, err, "send", "total", total == 2*len) end @@ -265,7 +265,7 @@ function test_blockingtimeoutsend(len, tm, sl) ]], 2*tm, len, sl, sl, len)) data:settimeout(tm) str = string.rep("a", 2*len) - total, err, elapsed = data:send(str) + total, err, partial, elapsed = data:send(str) check_timeout(tm, sl, elapsed, err, "send", "blocking", total == 2*len) end @@ -326,13 +326,13 @@ function test_closed() data:close() data = nil ]] - total, err = data:send(string.rep("ugauga", 100000)) + total, err, partial = data:send(string.rep("ugauga", 100000)) if not err then pass("failed: output buffer is at least %d bytes long!", total) elseif err ~= "closed" then fail("got '"..err.."' instead of 'closed'.") else - pass("graceful 'closed' received after %d bytes were sent", total) + pass("graceful 'closed' received after %d bytes were sent", partial) end end