mirror of
				https://github.com/lunarmodules/luasocket.git
				synced 2025-10-31 02:15:38 +01:00 
			
		
		
		
	Added support for FTP command lists
This commit is contained in:
		| @@ -243,7 +243,9 @@ non-numeric indices) in the arrays will be silently ignored. | |||||||
|  |  | ||||||
| <p class=return> The function returns a list with the sockets ready for | <p class=return> The function returns a list with the sockets ready for | ||||||
| reading, a list with the sockets ready for writing and an error message. | reading, a list with the sockets ready for writing and an error message. | ||||||
| The error message is "<tt>timeout</tt>" if a timeout condition was met and | The error message is "<tt>timeout</tt>" if a timeout | ||||||
|  | condition was met, "<tt>select failed</tt>" if the call | ||||||
|  | to <tt>select</tt> failed, and | ||||||
| <tt><b>nil</b></tt> otherwise. The returned tables are | <tt><b>nil</b></tt> otherwise. The returned tables are | ||||||
| doubly keyed both by integers and also by the sockets | doubly keyed both by integers and also by the sockets | ||||||
| themselves, to simplify the test if a specific socket has | themselves, to simplify the test if a specific socket has | ||||||
| @@ -251,7 +253,7 @@ changed status. | |||||||
| </p> | </p> | ||||||
|  |  | ||||||
| <p class=note> | <p class=note> | ||||||
| <b>Note: </b>: <tt>select</tt> can monitor a limited number | <b>Note:</b> <tt>select</tt> can monitor a limited number | ||||||
| of sockets, as defined by the constant <tt>socket._SETSIZE</tt>. This | of sockets, as defined by the constant <tt>socket._SETSIZE</tt>. This | ||||||
| number may be as high as 1024 or as low as 64 by default, | number may be as high as 1024 or as low as 64 by default, | ||||||
| depending on the system. It is usually possible to change this | depending on the system. It is usually possible to change this | ||||||
|   | |||||||
							
								
								
									
										13
									
								
								src/ftp.lua
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								src/ftp.lua
									
									
									
									
									
								
							| @@ -271,8 +271,17 @@ _M.command = socket.protect(function(cmdt) | |||||||
|     local f = _M.open(cmdt.host, cmdt.port, cmdt.create) |     local f = _M.open(cmdt.host, cmdt.port, cmdt.create) | ||||||
|     f:greet() |     f:greet() | ||||||
|     f:login(cmdt.user, cmdt.password) |     f:login(cmdt.user, cmdt.password) | ||||||
|     f.try(f.tp:command(cmdt.command, cmdt.argument)) |     if type(cmdt.command) == "table" then | ||||||
|     if cmdt.check then f.try(f.tp:check(cmdt.check)) end |         local argument = cmdt.argument or {} | ||||||
|  |         local check = cmdt.check or {} | ||||||
|  |         for i,cmd in ipairs(cmdt.command) do | ||||||
|  |             f.try(f.tp:command(cmd, argument[i])) | ||||||
|  |             if check[i] then f.try(f.tp:check(check[i])) end | ||||||
|  |         end | ||||||
|  |     else | ||||||
|  |         f.try(f.tp:command(cmdt.command, cmdt.argument)) | ||||||
|  |         if cmdt.check then f.try(f.tp:check(cmdt.check)) end | ||||||
|  |     end | ||||||
|     f:quit() |     f:quit() | ||||||
|     return f:close() |     return f:close() | ||||||
| end) | end) | ||||||
|   | |||||||
| @@ -22,6 +22,9 @@ _M.source = source | |||||||
| _M.sink = sink | _M.sink = sink | ||||||
| _M.pump = pump | _M.pump = pump | ||||||
|  |  | ||||||
|  | local unpack = unpack or table.unpack | ||||||
|  | local select = base.select | ||||||
|  |  | ||||||
| -- 2048 seems to be better in windows... | -- 2048 seems to be better in windows... | ||||||
| _M.BLOCKSIZE = 2048 | _M.BLOCKSIZE = 2048 | ||||||
| _M._VERSION = "LTN12 1.0.3" | _M._VERSION = "LTN12 1.0.3" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user