mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 04:28:20 +01:00
Changed the return of the send function...
This commit is contained in:
parent
597a062b1b
commit
07dda08c5d
@ -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
|
||||
|
@ -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
|
||||
|
12
src/buffer.c
12
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);
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user