index
minux software - netlib
this is a rednet networking library

netlib tries to create a rednet library that has actual confirmation the message got received by the other side
it contains a "simplified" system and an "advanced" system, each with it's own benefits.
it runs on Computercraft's rednet api and cannot access the real internet, there are other functions for that.

it comes with a small set of testing tools such as ping, getfile and sendfile
but mostly it provides a set of networking functions for other programs to use.


tools:
/bin/ping.sh - ping a system ID
use "ping ID" to ping a system

/bin/getfile.sh - receive a file
use "getfile ID filepath"
wait for ID to send a file using "sendfile", then store it as filepath

/bin/sendfile.sh - send a file
use "sendfile ID filepath"
offer filepath to ID

/bin/netlib.sh - network listen program
use "netlib" to run, terminate program (ctrl+c) to quit
listens for and responds to network calls, used for network diagnostics


basic programming functions
netlib.ping
used to ping another system to test networking
example: netlib.ping(ID)
input1: ID as a number
output: returns true if reply or false if not

netlib.getping
server side reply to ping for lazy people
example: netlib.getping(ID)
input1: ID to return ping to
output: always true

netlib.sendstring
send a string to ID
example: data = netlib.sendtring(ID,Data)
input1: receiving side id as number
input2: data to be send as string
output: true if received, false if not

netlib.getstring
receive a string from ID
example: data = netlib.getstring(ID,timeout)
input1: sender id as a number
input2: timeout in seconds as a number or nil(optional)
output: false if failed or string containing data if success

netlib.sendtable
send a table to ID
example: data = netlib.sendtable(ID,Data)
input1: receiving side id as number
input2: data to be send as table
output: true if received, false if not

netlib.gettable
receive a table from ID
example: data = netlib.gettable(ID,timeout)
input1: sender id as a number
input2: timeout in seconds as a number or nil(optional)
output: false if failed or table containing data if success

advanced programming functions
netlib.getsid
get a session id from a server
example: data = netlib.getsid(id)
input1: server id as a number
output: session id or 1100 if fail

netlib.sendsid
send a session id from to a client
example: netlib.sendsid(id)
input1: client id as a number
output: always truew

netlib.connect
establish a connection to a server
example: data = netlib.connect(id, sid)
input1: server id as a number
input2: session id as a number
output:true if success, error code if fail

netlib.opensocket
establish a connection with a client
example: data = netlib.opensocket(packet)
input1: data packet as a table
output: true if success, error code if fail

netlib.closesocket
close a connection from a client
example: data = netlib.closesocket(packet,client)
input1: data packet as table
input2: client id
output: true if closed, error code if not

netlib.endsocket
end a socket server side (eg:timeout)
example: netlib.endsocket(sid)
input1: session id as number
output: always true

netlib.disconnect
close a connection with a server
example: data = netlib.disconnect(id, sid)
input1: server id as number
input2: session id as number

netlib.cleanup
function to clean up connection data, run periodically on servers
example: netlib.cleanup()
no input, no output

netlib.timeout
resets a connection's timeout timer avoiding cleanup killing it
example: data = netlib.timeout(sid)
input1: session id as a number
output: true if success, false if not

netlib.ass
send a string
example: netlib.ass(header,sid,data)
input1: packet header as string
input2: session id as number
input3: data as string
output: true if success, code if fail

netlib.ags
receive a string
example: netlib.ags(sid,timeout)
input1: session id as number
input2: timeout in seconds as number
output: either data string or error code

netlib.ast
send a table
example: netlib.ast(header,sid,data)
input1: packet header as string
input2: session id as number
input3: data as table
output: true or error code

netlib.agt
receive a table
example: netlib.agt(sid,timeout)
input1: session id as number
input2: timeout in seconds as number
output: either table or error code