@@ -70,6 +70,7 @@ print("value", value1, value2)]]
7070-- # define TEST_PIPENAME_2 "/tmp/uv-test-sock2"
7171-- #endif
7272
73+
7374if context .winos then
7475 package.cpath = package.cpath .. " ;" .. " ..\\ clib\\ ?.dll"
7576 package.path = package.path .. " ;" .. " ..\\ lualib\\ ?.lua"
7879 package.path = package.path .. " ;" .. " ../lualib/?.lua"
7980end
8081
81- for i = 1 , 32 do
82- context .create (" test.lua" , 1 , 2 , 3 )
83- end
84- do return end
82+ -- for i = 1, 32 do
83+ -- context.create("test.lua", 1, 2, 3)
84+ -- end
85+ -- do return end
8586
8687local ret , sock = tcp .listen (" 0.0.0.0" , 8801 )
8788if not ret then
8889 print (" tcp.listens failed: " , context .strerror (sock ))
8990else
9091 print (" tcp.listens success: " , sock )
91- sock :accept (function (result , accept_sock ) print (" sock:accept" , result , accept_sock ) sock :close () accept_sock :set_nodelay (false ) accept_sock :write (" hello world!" ) end )
92+ sock :accept (function (result , accept_sock )
93+ print (" sock:accept" , result , accept_sock )
94+ sock :close ()
95+ -- accept_sock:set_nodelay(false)
96+ accept_sock :set_rwopt ({ read_head_endian = " L" , read_head_bytes = 2 , read_head_max = 65535 , write_head_endian = " L" , write_head_bytes = 2 , write_head_max = 65535 ,})
97+ accept_sock :set_wshared (true )
98+ print (" accept_sock:fd" , accept_sock :fd ())
99+ tcp .write2 (accept_sock :fd (), " hello world!" )
100+ accept_sock :write (" hello world!" )
101+ tcp .write2 (accept_sock :fd (), " hello world!" )
102+ tcp .write2 (accept_sock :fd (), " hello world!" )
103+ accept_sock :write (" hello world!" )
104+ end )
92105 local ret , con_sock = tcp .connect (" 127.0.0.1" , 8801 )
93106 if ret then
94107 print (" tcp.connect" , ret , con_sock )
108+ con_sock :set_rwopt ({ read_head_endian = " L" , read_head_bytes = 2 , read_head_max = 65535 , write_head_endian = " L" , write_head_bytes = 2 , write_head_max = 65535 ,})
109+ con_sock :set_wshared (true )
110+ local ret , buffer = con_sock :read ()
111+ print (" tcp read" , ret , ret and buffer :tostring ())
112+ local ret , buffer = con_sock :read ()
113+ print (" tcp read" , ret , ret and buffer :tostring ())
114+ local ret , buffer = con_sock :read ()
115+ print (" tcp read" , ret , ret and buffer :tostring ())
95116 local ret , buffer = con_sock :read ()
96117 print (" tcp read" , ret , ret and buffer :tostring ())
97118 else
0 commit comments