Protected ReadonlybaseProtected ReadonlytrappedProtected ReadonlyuntrappedReadonlysizeReadonlyabortremove an address "trap", so that it will no longer be filtered. the returned value will contain all unread messages that had been trapped for the given address.
read incoming messages from a certain "trapped" address.
remember, if a message from a certain address, addr,
made its way through before you add that address to the list of trapped addresses (via trapAddr),
then that message will end up in the "untrapped" category, and you will not receive it through this method.
read incoming "untrapped" messages, that do not fit into any of the existing address traps (added via trapAddr).
returns the number of remaining untrapped unread messages. the value may be negative, indicating that one or more things have already requested to snatch the message as soon as it comes.
send the contents of the array buffer to a host with the addr network-address, over your connection.
resolves to the number of bytes written. though it is kind of pointless given the TODO conundrum below:
TODO: what should we do about input buffers that are not entirely sent in a single packet? should the implementation loop until all of it has been sent? or should it be up to the user of this interface to do that on their own?
for now, I will enforce the rule that the send method must completely send the buffer before resolving its promise.
it really makes things simpler for the end user,
and it only adds one line of code for underlying implementations that do not necessarily send their buffer all in one go.
closes the connection on your local device to free up resources.
Protectedinitthis infinite loop reads all messages as they come in, and then organizes them as needed.
a net-connection sink traps certain messages received from specific
hostnames (ip-addresses), while queuing the rest of messages elsewhere.you can think of it as network-connection with a builtin hostname filter system, allowing you prioritize the reading of incoming messages from a certain hostname, and later take care of the remaining un-organized/untrapped set of messages, when nothing of high-priority is taking place.
the way it works is that you must first set a
hostname"trap" via the the trapAddr method, and then, to read incoming messages coming fromhostname, you will use the readAddr method to receive the messages, one at a time.