Comparison

net/server_select.lua @ 2603:3a77cc94b85c

Merge with trunk.
author Waqas Hussain <waqas20@gmail.com>
date Fri, 12 Feb 2010 02:50:57 +0500
parent 2598:8a021b304765
child 2728:3f8d9319d4a3
child 2996:b0515ed4d9d7
comparison
equal deleted inserted replaced
2602:dff84fdebac0 2603:3a77cc94b85c
53 local coroutine_wrap = coroutine.wrap 53 local coroutine_wrap = coroutine.wrap
54 local coroutine_yield = coroutine.yield 54 local coroutine_yield = coroutine.yield
55 55
56 --// extern libs //-- 56 --// extern libs //--
57 57
58 local luasec = select( 2, pcall( require, "ssl" ) ) 58 local luasec = use "ssl"
59 local luasocket = require "socket" 59 local luasocket = use "socket" or require "socket"
60 60
61 --// extern lib methods //-- 61 --// extern lib methods //--
62 62
63 local ssl_wrap = ( luasec and luasec.wrap ) 63 local ssl_wrap = ( luasec and luasec.wrap )
64 local socket_bind = luasocket.bind 64 local socket_bind = luasocket.bind
470 bufferqueuelen = 0 470 bufferqueuelen = 0
471 bufferlen = 0 471 bufferlen = 0
472 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) -- delete socket from writelist 472 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) -- delete socket from writelist
473 _ = needtls and handler:starttls(nil, true) 473 _ = needtls and handler:starttls(nil, true)
474 _writetimes[ handler ] = nil 474 _writetimes[ handler ] = nil
475 _ = toclose and handler.close( ) 475 _ = toclose and handler.close( )
476 return true 476 return true
477 elseif byte and ( err == "timeout" or err == "wantwrite" ) then -- want write 477 elseif byte and ( err == "timeout" or err == "wantwrite" ) then -- want write
478 buffer = string_sub( buffer, byte + 1, bufferlen ) -- new buffer 478 buffer = string_sub( buffer, byte + 1, bufferlen ) -- new buffer
479 bufferqueue[ 1 ] = buffer -- insert new buffer in queue 479 bufferqueue[ 1 ] = buffer -- insert new buffer in queue
480 bufferqueuelen = 1 480 bufferqueuelen = 1
599 handshake( socket ) -- do handshake 599 handshake( socket ) -- do handshake
600 end 600 end
601 handler.readbuffer = _readbuffer 601 handler.readbuffer = _readbuffer
602 handler.sendbuffer = _sendbuffer 602 handler.sendbuffer = _sendbuffer
603 end 603 end
604 end 604 else
605 605 handler.readbuffer = _readbuffer
606 handler.sendbuffer = _sendbuffer
607 end
606 send = socket.send 608 send = socket.send
607 receive = socket.receive 609 receive = socket.receive
608 shutdown = ( ssl and id ) or socket.shutdown 610 shutdown = ( ssl and id ) or socket.shutdown
609 611
610 _socketlist[ socket ] = handler 612 _socketlist[ socket ] = handler