add nodelay option in socketchannel

This commit is contained in:
Cloud Wu
2014-10-13 20:58:41 +08:00
parent 883757b936
commit a074cd79bd
3 changed files with 8 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
local skynet = require "skynet"
local socket = require "socket"
local socketdriver = require "socketdriver"
-- channel support auto reconnect , and capture socket error in request/response transaction
-- { host = "", port = , auth = function(so) , response = function(so) session, data }
@@ -37,6 +38,7 @@ function socket_channel.channel(desc)
__sock = false,
__closed = false,
__authcoroutine = false,
__nodelay = desc.nodelay,
}
return setmetatable(c, channel_meta)
@@ -186,6 +188,9 @@ local function connect_once(self)
return false
end
end
if self.__nodelay then
socketdriver.nodelay(fd)
end
self.__sock = setmetatable( {fd} , channel_socket_meta )
skynet.fork(dispatch_function(self), self)