Difference between revisions of "socket"

(Added link to Tutorial:Networking with UDP)
m (0.11.0 -> 11.0)
 
(13 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 +
{{notice|Since [[11.0]], LÖVE does fully support non-blocking TCP connections on Windows}}
 
{{newin|[[0.5.0]]|050|type=module}}
 
{{newin|[[0.5.0]]|050|type=module}}
 
 
Implements a [http://w3.impa.br/~diego/software/luasocket/ luasocket] module for TCP/UDP networking.
 
Implements a [http://w3.impa.br/~diego/software/luasocket/ 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:
 
The luasocket module is bundled with love binary, but in order to use it, you need to require the module like this:
 
<source lang="lua">
 
<source lang="lua">
require ("socket")
+
require("socket")
 
</source>
 
</source>
 
or even better:
 
or even better:
 
<source lang="lua">
 
<source lang="lua">
local socket=require ("socket")
+
local socket = require("socket")
 
</source>
 
</source>
  
'''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 <s>lua 5.2</s> LÖVE 11.0, the latter method is <s>preferred</s> recommended, as modules will no longer register themselves in the global space, instead they will return a table.
  
'''Note:''' When using blocking operations (network connect/read/write, or socket.sleep), the whole LÖVE mainloop 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 non-blocking operations if possible, or use it in a thread.
  
 
== Reference Manual ==
 
== Reference Manual ==
Line 19: Line 19:
  
 
== See Also ==
 
== See Also ==
* [[parent::LUBE]]
+
* [[parent::love]]
 
* [[Tutorial:Networking with UDP]]
 
* [[Tutorial:Networking with UDP]]
 +
* [[enet]]
 +
* [https://love2d.org/forums/viewtopic.php?f=5&t=230 LUBE]
 
[[Category:Libraries]]
 
[[Category:Libraries]]
{{#set:Description=Implements a [http://w3.impa.br/~diego/software/luasocket/ luasocket] module for TCP/UDP networking.}}
+
{{#set:Description=Module for HTTP, TCP, and UDP networking.}}
 
{{#set:LOVE Version=0.5.0}}
 
{{#set:LOVE Version=0.5.0}}
 +
{{#set:Keyword=Networking}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|socket}}
 
{{i18n|socket}}

Latest revision as of 13:39, 5 January 2019

O.png Since 11.0, LÖVE does fully support non-blocking TCP connections on Windows  

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 LÖVE 11.0, the latter method is preferred recommended, as modules will no longer register themselves in the global space, instead they will return a table.

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 non-blocking operations if possible, or use it in a thread.

Reference Manual

For detailed usage, see the reference manual.

See Also


Other Languages