Difference between revisions of "socket"

m (Undo revision 16331 by Unek (talk))
m (Added threading suggestion.)
Line 12: Line 12:
 
'''Note:''' Since lua 5.2 the latter method is preferred, as modules will no longer register theirselves in the global space, instead returning a table. So this method is recomended.
 
'''Note:''' Since lua 5.2 the latter method is preferred, as modules will no longer register theirselves in the global space, instead returning a table. So this method is recomended.
  
'''Note:''' When using blocking operations (network connect/read/write, or socket.sleep), the whole LÖVE main loop will be blocked, and it is usually a bad idea. So use only nonblocking operations if possible.
+
'''Note:''' When using blocking operations (network connect/read/write, or socket.sleep), the whole LÖVE main loop will be blocked, and it is usually a bad idea. So use only nonblocking operations if possible, or use it in a thread.
  
 
== Reference Manual ==
 
== Reference Manual ==

Revision as of 09:49, 31 January 2017

Available since LÖVE 0.5.0
This module is not supported in earlier versions.

Implements a luasocket module for TCP/UDP networking. The luasocket module is bundled with love binary, but in order to use it, you need to require the module like this:

require("socket")

or even better:

local socket = require("socket")

Note: Since lua 5.2 the latter method is preferred, as modules will no longer register theirselves in the global space, instead returning a table. So this method is recomended.

Note: When using blocking operations (network connect/read/write, or socket.sleep), the whole LÖVE main loop will be blocked, and it is usually a bad idea. So use only nonblocking operations if possible, or use it in a thread.

Reference Manual

For detailed usage, see the reference manual.

See Also


Other Languages