lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Gunnar Zötl wrote:
You can get lpty from http://www.tset.de/lpty/ or from the luarocks repository.

I think better is luasocket-alike interface:
1. read() can be renamed to receive()
btw, read/send pair is strange.
2. In luasocket only one receive function return error message too:
If successful, the method returns the received pattern. In case of error, the method returns *nil* followed by an error message
3. Your version of send() did not understand partial writes, in luasocket:
client:*send(*data [, i [, j]]*)*

Sends data through client object.

Data is the string to be sent. The optional arguments i and j work exactly like the standard string.sub Lua function to allow the selection of a substring to be sent.

If successful, the method returns the index of the last byte within [i, j] that has been sent. Notice that, if i is 1 or absent, this is effectively the total number of bytes sent. In case of error, the method returns *nil*, followed by an error message, followed by the index of the last byte within [i, j] that has been sent. 4. You define sendok() and readok(), but sometimes better is check several file descriptors in one select/poll call.
luasocket provide getfd() function for this.