Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tony48 committed Dec 5, 2020
2 parents 144b781 + eef8e37 commit 8cc727b
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,48 @@
# kOS.Utils

## Table of contents
- [Sockets](https://github.com/tony48/kOS.Utils/blob/master/README.md#sockets)
- [Orbital functions](https://github.com/tony48/kOS.Utils#orbital-functions)
- [Input](https://github.com/tony48/kOS.Utils#input)
- [Screen](https://github.com/tony48/kOS.Utils#screen)
- [Impact Prediction](https://github.com/tony48/kOS.Utils#impact-prediction) (see Predictor if you are looking for predictions on atmopheric bodies)
- [Predictor](https://github.com/tony48/kOS.Utils#predictor)
- [Breaking Ground](https://github.com/tony48/kOS.Utils#breakingground)

## Sockets

### Addon

To access socket functions, use ADDONS:SOCK.
Example : ADDONS:SOCK:CONNECT("127.0.0.1", 11000).

- Connect(string ipAddress, scalar port)

Returns a kOSSocket object and connect it to a server socket at the given IP address and port.

### kOSSocket

- Send(string message)

Send a message to the socket server. THE SERVER MUST DECODE THE MESSAGE AS UTF-8.

- Queue

Returns the message queue. All the received messages are in the queue. See [here](https://ksp-kos.github.io/KOS/structures/collections/queue.html) for the queue documentation. THE SERVER MUST SEND ALL THE MESSAGES IN UTF-8.

- Close()

Close the socket.

### Example script

```
set socket to addons:sock:connect("127.0.0.1", 11000). // create a socket and connect it to 127.0.0.1:11000
socket:send("This is a test"). // Send "This is a test"
wait until not socket:queue:empty. // Wait until we have receiced something
print socket:queue:pop(). // print the received message and remove it from the queue
```

## Orbital functions

To access orbital functions, use ADDONS:OBT.
Expand Down

0 comments on commit 8cc727b

Please sign in to comment.