The network library allows to connect computers within the same network. I suggest you explore examples available in the forum or available in the examples provided by Processing. For instance, you can check the examples that comes with the oscP5 library (You need to install it using the contribution manager). Then you need to load two sketches, one with the server and another with the client app and make them talk to each other. You will need some minor changes (I encourage you to try to figure it out yourself so it will help you become familiar with the concepts).
To connect to the internet, it really depends on your requirements as in what you want to do. For instance if you want to save the information on a server, you can create a simple server application and communicate with it using http request. You can try free hosting options like atspace.com or webhost000 (I think that is what it is). You can also try GCP as it has a free tier but it requires that you provide a credit card. But no need to go online if you are still in your path to master the concepts. You can try implementing a local server first. This will also make debugging a bit easier.
For sockets, it is possible and if not available, you could implement the Java way. After all Processing is Java.
I strongly suggest you check the happycodding.io website as it provides some guides to get you started.