2
0
Björn Ritzl 6 жил өмнө
parent
commit
05730d6090

+ 4 - 4
docs/en/manuals/networking.md

@@ -22,7 +22,7 @@ http.request("https://www.defold.com", "GET", handle_response)
 
 This will make an HTTP GET request to https://www.defold.com. The function is asynchronous and will not block while making the request. Once the request has been made and a server has sent a response it will invoke/call the provided callback function. The callback function will receive the full server response, including status code and response headers. It is also possible to make HTTP POST requests to pass data to the server and to specify request headers. Refer to the [API reference](/ref/http/) to learn more.
 
-Using HTTP requests allows you to connect to and interact with thousands of different services on the internet. In most cases there's more to it than simply making an HTTP request. You usually need to use some kind of authenticate, the request data may need to be formatted in a certain way and the response may need to be parsed before it can be used. This can of course be done manually by you but there are also extensions and libraries to take care of this sort of thing for you. Below you'll find a list of some extensions that can be used to more easily interact with specific backend services:
+Using HTTP requests allows you to connect to and interact with thousands of different services on the internet, but in most cases there's more to it than simply making an HTTP request. You usually need to use some kind of authenticate, the request data may need to be formatted in a certain way and the response may need to be parsed before it can be used. This can of course be done manually by you but there are also extensions and libraries to take care of this sort of thing for you. Below you'll find a list of some extensions that can be used to more easily interact with specific backend services:
 
 * [AWS SDK](https://github.com/britzl/aws-sdk-lua) - Use Amazon Web Services from within your game
 * [Colyseus](https://github.com/colyseus/colyseus-defold) - Multiplayer game client
@@ -42,9 +42,9 @@ Defold includes the [LuaSocket library](http://w3.impa.br/~diego/software/luasoc
 ```Lua
 local client = socket.tcp()
 client:connect("127.0.0.1", 8123)
-client:settimeout(0) -- non blocking socket
-client:send("foobar") -- send data like this
-local response = client:receive("*l") -- receive a "line" of data like this
+client:settimeout(0)
+client:send("foobar")
+local response = client:receive("*l")
 ```
 
 This will create a TCP socket, connect it to IP 127.0.0.1 (localhost) and port 8123. It will set timeout to 0 to make the socket non-blocking and it will send the string "foobar" over the socket. It will also read a line of data (bytes ending with a newline character) from the socket. Note that the above example doesn't contain any kind of error handling. Refer to the [API reference](/ref/socket/) to learn more about the functionality available via LuaSocket. The [official LuaSocket documentation](http://w3.impa.br/~diego/software/luasocket/) also contains many examples of how to work with the library. There is also some examples and helper modules in the [DefNet library](https://github.com/britzl/defnet/).