Difference between revisions of "socket"

(add keyword field)
m
 
(18 intermediate revisions by 12 users not shown)
Line 2: Line 2:
 
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">
 
require("socket")
 
</source>
 
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.
+
== Notes ==
 
+
* Prior to [[11.0]], LÖVE doesn't fully supports non-blocking TCP connections on Windows
'''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.
+
* Starting with LÖVE 11.0, <code>require("socket")</code> no longer creates a global variable.
 +
* 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 [[love.thread|thread]].
  
 
== Reference Manual ==
 
== Reference Manual ==
For detailed usage, see the [http://w3.impa.br/~diego/software/luasocket/reference.html reference manual].
+
For detailed usage, see the [https://w3.impa.br/~diego/software/luasocket/reference.html reference manual] ([https://web.archive.org/web/20200510190501/http://w3.impa.br/~diego/software/luasocket/reference.html backup link]).
  
 
== See Also ==
 
== See Also ==
 
* [[parent::love]]
 
* [[parent::love]]
 
* [[Tutorial:Networking with UDP]]
 
* [[Tutorial:Networking with UDP]]
* [[enet]]
+
* [[lua-enet]]
* [https://love2d.org/forums/viewtopic.php?f=5&t=230 LUBE]
+
* [https://github.com/bartbes/love-misc-libs/blob/master/grease/docs.md grease]
 
[[Category:Libraries]]
 
[[Category:Libraries]]
 +
[[Category:ThirdParty]]
 
{{#set:Description=Module for HTTP, TCP, and 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}}
 
{{#set:Keyword=Networking}}
 +
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|socket}}
 
{{i18n|socket}}

Latest revision as of 03:04, 5 July 2023

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:

local socket = require("socket")

Notes

  • Prior to 11.0, LÖVE doesn't fully supports non-blocking TCP connections on Windows
  • Starting with LÖVE 11.0, require("socket") no longer creates a global variable.
  • 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 (backup link).

See Also



Other Languages