-
Notifications
You must be signed in to change notification settings - Fork 1
API: net
Networking! Yay! if user.Valid() { # store userResponse.User.Id in your user database }
Returns either a socket as the first return value or an error as the second.
proto
is the type of socket, most likely "tcp"
or "udp"
. address
self-explanatory.
Writes content
to the socket, without newlines or anything appended to it.
Reads at max count
bytes and returns the read bytes as a string or an error as its second return value.
A common error is "EOF"
, which just means that there are no bytes left to read at this point in time.
Reads til a newline appears or an "EOF"
error happens. You should most likely just use net.read
, since net.readline
may cause loss of bytes in some cases.
Tries to create a listening socket, listening on address
. proto
could be "tcp"
or "udp"
. address
can be something like ":1234"
or "127.0.0.1:1234"
.
Waits for a connection and returns its socket for further use with the net
functions. If error
then accepting failed and the socket is not to be used.
You most likely want to run this in a loop and spawn threads handeling the socket.