diff --git a/NEW b/NEW index e5efc97..34eac97 100644 --- a/NEW +++ b/NEW @@ -1,17 +1,21 @@ -All functions provided by the library are in the namespace "socket". -Functions such as send/receive/timeout/close etc do not exist in the -namespace. They are now only available as methods of the appropriate -objects. +Major C code rewrite. Code is modular and extensible. Hopefully, next +versions will include code for local domain sockets, file descriptors, +pipes (on unix) and named pipes (on windows) as a bonus. -Object has been changed to become more uniform. First create an object for -a given domain/family and protocol. Then connect or bind if needed. Then -use IO functions. +All functions provided by the library are in the namespace "socket". +Functions such as send/receive/timeout/close etc do not exist anymore as +stand alone functions. They are now only available as methods of the +appropriate objects. + +TCP has been changed to become more uniform. First create an object, then +connect or bind if needed. Then use IO functions. The "socket.connect" and +"socket.bind" functions are provided for simplicity, but they just call +"socket.tcp" followed by the ":connect" or ":bind" methods. All functions return a non-nil value as first return value if successful. All functions return whatever could be retrieved followed by error message in case of error. The best way to check for errors is to check for the -presence of an error message. -WARNING: The send function was affected. +presence of an error message. WARNING: The send function was affected. Better error messages and parameter checking. @@ -20,3 +24,6 @@ setpeername with address "*". socket.sleep and socket.time are now part of the library and are supported. + +Socket options interface has been improved and TCP now also supports socket +options. diff --git a/README b/README index 091ce6f..611d2a2 100644 --- a/README +++ b/README @@ -1,12 +1,9 @@ This release is work in progress. It has been tested on WinXP, Mac OS X, -SunOS and Linux. The most important change is a major rewrite of the C code -that attempts to make the library extensible. Also, all functions were -moved to the 'socket' namespace. A few changes are expected for the final -version, mostly in order to make the API more uniform. +SunOS and Linux. -In this version, all Lua code has been built into the binary. For that, you +In this version, all Lua code should be built into the binary. For that, you will need a working versions of luac and bin2c, both available with your -Lua distribution. Check makefile for details. +Lua distribution. Check the makefile for details. Have fun, Diego Nehab. diff --git a/TODO b/TODO index 5c2492d..ffc1ab0 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,4 @@ - Melhorar a interface de setoptions (aceitar nada como true, por exemplo) -- Inicializaccao das classes pode falhar? -- Ajeitar melhor a hierarquia de classes. Ajeitar o file... -- GARBAGE COLLECTOR! -- Adicionar um método sock:setoption??? - testar em várias plataformas - adicionar exemplos de expansão: pipe, local, named pipe diff --git a/makefile.dist b/makefile.dist index 9cf2757..353467b 100644 --- a/makefile.dist +++ b/makefile.dist @@ -5,46 +5,45 @@ DIST = luasocket-2.0-alpha LUA = \ -auxiliar.lua -code.lua -concat.lua -ftp.lua + auxiliar.lua \ + code.lua \ + concat.lua \ + ftp.lua \ + http.lua \ + select.lua \ + smtp.lua \ + url.lua TESTS = \ -codetest.lua -concattest.lua -ftptest.lua + codetest.lua \ + concattest.lua \ + ftptest.lua \ + mbox.lua \ + httptest.lua \ + noglobals.lua \ + smtptest.lua \ + testclnt.lua \ + testsrvr.lua \ + udptest.lua \ + urltest.lua EXAMPLES = \ -check-links.lua -daytimeclnt.lua -echoclnt.lua -echosrvr.lua -dict.lua + daytimeclnt.lua \ + echoclnt.lua \ + echosrvr.lua \ + dict.lua \ + listener.lua \ + talker.lua \ + tinyirc.lua ETC = \ -cl-compat.lua + check-links.lua \ + cl-compat.lua \ + get.lua \ + lua.lua \ + luasocket.lua \ + tftp.lua \ -get.lua -http.lua -httptest.lua -listener.lua -lua.lua -luasocket.lua -mbox.lua -noglobals.lua -select.lua -smtp.lua -smtptest.lua -talker.lua -testclnt.lua -test.lua -testsrvr.lua -tftp.lua -tinyirc.lua -udptest.lua -url.lua -urltest.lua MAIN = \ auxiliar.c \ @@ -57,10 +56,8 @@ MAIN = \ inet.h \ io.c \ io.h \ - lua.c \ luasocket.c \ luasocket.h \ - makefile \ select.c \ select.h \ socket.h \ @@ -73,23 +70,24 @@ MAIN = \ usocket.c \ usocket.h \ wsocket.c \ - wsocket.h \ + wsocket.h dist: mkdir -p $(DIST)/examples mkdir -p $(DIST)/tests mkdir -p $(DIST)/etc - mkdir -p $(DIST)/lua cp -vf $(MAIN) $(DIST) cp -vf $(LUA) $(DIST) cp -vf makefile $(DIST) cp -vf README $(DIST) + cp -vf lua.README $(DIST) + cp -vf NEW $(DIST) cp -vf $(EXAMPLES) $(DIST)/examples - cp -vf README.examples $(DIST)/examples/README + cp -vf examples.README $(DIST)/examples/README cp -vf $(TESTS) $(DIST)/tests - cp -vf README.tests $(DIST)/tests/README + cp -vf tests.README $(DIST)/tests/README cp -vf $(ETC) $(DIST)/etc - cp -vf README.etc $(DIST)/etc/README + cp -vf etc.README $(DIST)/etc/README tar -zcvf $(DIST).tar.gz $(DIST) zip -r $(DIST).zip $(DIST) diff --git a/test/testclnt.lua b/test/testclnt.lua index 20ef0b6..b58ca2b 100644 --- a/test/testclnt.lua +++ b/test/testclnt.lua @@ -120,6 +120,7 @@ test_methods(socket.tcp(), { "setsockname", "getpeername", "getsockname", + "setoption", "timeout", "close", }) @@ -133,6 +134,7 @@ test_methods(socket.udp(), { "sendto", "receive", "receivefrom", + "setoption", "timeout", "close", }) @@ -162,21 +164,16 @@ remote "data:send(str); data:close()" end ---test_mixed(1) ---test_mixed(17) ---test_mixed(200) ---test_mixed(4091) ---test_mixed(80199) ---test_mixed(4091) ---test_mixed(200) ---test_mixed(17) ---test_mixed(1) +test_mixed(1) +test_mixed(17) +test_mixed(200) +test_mixed(4091) +test_mixed(80199) +test_mixed(4091) +test_mixed(200) +test_mixed(17) +test_mixed(1) -test_mixed(4091) -test_mixed(4091) -test_mixed(4091) -test_mixed(4091) -test_mixed(4091) ------------------------------------------------------------------------ test("character line") reconnect() @@ -203,6 +200,11 @@ test_asciiline(200) test_asciiline(4091) test_asciiline(80199) test_asciiline(800000) +test_asciiline(80199) +test_asciiline(4091) +test_asciiline(200) +test_asciiline(17) +test_asciiline(1) ------------------------------------------------------------------------ test("binary line") @@ -479,9 +481,7 @@ function test_selectbugs() pass("invalid input: ok") end --- test_selectbugs() - - +test_selectbugs() test(string.format("done in %.2fs", socket.time() - start))