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
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "smtp", "smtp.vcproj", "{128E8BD0-174A-48F0-8771-92B1E8D18713}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfiguration) = preSolution
|
GlobalSection(SolutionConfiguration) = preSolution
|
||||||
Debug = Debug
|
Debug = Debug
|
||||||
@ -25,10 +21,6 @@ Global
|
|||||||
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug.Build.0 = 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.ActiveCfg = Release|Win32
|
||||||
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id$
|
-- RCS ID: $Id$
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
require("socket")
|
socket = require("socket")
|
||||||
host = host or "localhost"
|
host = host or "localhost"
|
||||||
port = port or 8080
|
port = port or 8080
|
||||||
if arg then
|
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);
|
err = sendraw(buf, data, count, &sent);
|
||||||
total += sent;
|
total += sent;
|
||||||
}
|
}
|
||||||
lua_pushnumber(L, total);
|
/* check if there was an error */
|
||||||
io_pusherror(L, err);
|
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
|
#ifdef LUASOCKET_DEBUG
|
||||||
/* push time elapsed during operation as the last return value */
|
/* push time elapsed during operation as the last return value */
|
||||||
lua_pushnumber(L, (tm_gettime() - tm_getstart(tm))/1000.0);
|
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))
|
]], 2*tm, len, sl, sl, len))
|
||||||
data:settimeout(tm, "total")
|
data:settimeout(tm, "total")
|
||||||
str = string.rep("a", 2*len)
|
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",
|
check_timeout(tm, sl, elapsed, err, "send", "total",
|
||||||
total == 2*len)
|
total == 2*len)
|
||||||
end
|
end
|
||||||
@ -265,7 +265,7 @@ function test_blockingtimeoutsend(len, tm, sl)
|
|||||||
]], 2*tm, len, sl, sl, len))
|
]], 2*tm, len, sl, sl, len))
|
||||||
data:settimeout(tm)
|
data:settimeout(tm)
|
||||||
str = string.rep("a", 2*len)
|
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",
|
check_timeout(tm, sl, elapsed, err, "send", "blocking",
|
||||||
total == 2*len)
|
total == 2*len)
|
||||||
end
|
end
|
||||||
@ -326,13 +326,13 @@ function test_closed()
|
|||||||
data:close()
|
data:close()
|
||||||
data = nil
|
data = nil
|
||||||
]]
|
]]
|
||||||
total, err = data:send(string.rep("ugauga", 100000))
|
total, err, partial = data:send(string.rep("ugauga", 100000))
|
||||||
if not err then
|
if not err then
|
||||||
pass("failed: output buffer is at least %d bytes long!", total)
|
pass("failed: output buffer is at least %d bytes long!", total)
|
||||||
elseif err ~= "closed" then
|
elseif err ~= "closed" then
|
||||||
fail("got '"..err.."' instead of 'closed'.")
|
fail("got '"..err.."' instead of 'closed'.")
|
||||||
else
|
else
|
||||||
pass("graceful 'closed' received after %d bytes were sent", total)
|
pass("graceful 'closed' received after %d bytes were sent", partial)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user