# Networking made "easy": Network Objects library

**URL:** <https://discourse.processing.org/t/networking-made-easy-network-objects-library/31059>\
**Category:** Gallery\
**Created:** [July 4, 2021, 11:27pm UTC](https://discourse.processing.org/t/networking-made-easy-network-objects-library/31059 "2021-07-04T23:27:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shwaa](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shwaa/32/9696_2.png) [@Shwaa](https://discourse.processing.org/u/Shwaa)\
**Post date:** [July 4, 2021, 11:27pm UTC](https://discourse.processing.org/t/networking-made-easy-network-objects-library/31059/1 "2021-07-04T23:27:39Z")

</div>

Hello,  
After working with processing’s built-in network library for some time, I noticed that there were certain aspects of the library that made managing Clients and sending Objects over the network unintuitive, cumbersome, or repetitive. This inspired me to make a wrapper class that uses the built-in network library to easily manage connections and send and receive Objects over the internet. The project eventually became my Network Objects Library, which is posted publicly on [Github](https://github.com/shua5115/NetworkObjects).  
The premise of the library is that all Objects you want to send over the network implement the `Packet` interface, which requires that the Object can be converted to and constructed from a `byte[]`. A static class `ByteOps`, short for Byte Operations, has methods that can convert all primitives and Strings to and from a `byte[]`, and can modify `byte[]`s by combining, slicing, or shortening them. This facilitates the conversion of instance variables in a `Packet`.  
Finally, the `NetworkIO` object manages all connections and sends `Packet`s over the network. The `NetworkIO` has a built-in server and can connect to any number of external servers, so you could reasonably manage all of a program’s network traffic through a single `NetworkIO` instance. Clients and external connections are kept track of with Maps that associate an IP address with data. Incoming `Packet`s are stored in Queues, where the oldest `Packet`s are first. All you have to do is put certain methods in the `serverEvent()`, `clientEvent()`, and `disconnectEvent()` methods to make things work.  
While the library works (you can test it with the provided example), it has a couple of features that need improvement:

1. Method names can be confusing, and there are a lot of methods. In the future, I may make a 2.0.0 version that refactors method names and design.
2. There is no protection for DDOS attacks, the NetworkIO’s buffers may get stuck if filled with too much junk. I am thinking of a solution to this, but I have no background in cybersecurity. For now, be careful who you let connect to your device.

This is the first library I have created (ever), so its quality may leave some things to be desired. However, I hope that some of you may find this useful and incorporate it into your projects. Feel free to fork the project on Github, make suggestions, or report bugs.  
Thanks!  
-Shwaa
