DevLog 15
Been busy the past couple of days with some school, so sorry I haven’t posted sooner, but I have also built out a couple more features.The Main additions are;
- Reusable frequent packet structures (acknowledge, negative acknowledge, reset link)
- Server Client loop
1. Ability to choose packet type to send to server (through TUI) in client
2. Server responds, and client is able to display response - Better error handling, with more checks for errno and printing to log and console
- Better logging through file rather than just console
The logging is proably my favorite new feature. It saves previous runs and even annotates the time and date the run took place. The error info is also much more helpful, and more often my program tells me why it crashed, instead of just ending or segfaulting
client [main]: Connection refused
^^^^ This now happens when you try to run the client with out a server on the configured adress or port
Errors I ran into
There actually wasn’t that much stuff going wrong, just took me pretty long as I had to edit a lot of functions and flows.
A big issue i did run into was adding select(), also know as polling to the socket. Basicly, my code will loop checking the socket and parsing the data in it. But, a problem occurs if there is no data in the socket waiting.
Polling allows my code to check if there actually is data, and if not wait/move on to the next task. But, I had incorrectly configured the function (the documentation for this function is especially confusing…), and this lead it to always report data in the socket. This then lead to errors with trying to map that data into a struct, and it just lead to catastrophy.
Immediate Plans
Have some stuff I’m going to / want to try and start before the next devlog;
- Logging Functions to simply logging to console and file
* Something likelog_note(),log_warn(), andlog_error()
* Currently just writing bothfprintf()andperror() - Add functionality to digital and analog requests * Need to add packet structures and creator functions for both
- Seperate network functionality like
socket(),send(), etc… into its own library fucntions - Seperate shared code between server and client into common library
Media
I thought I would include this section to explain some of things in the attached videos. These show all the features I implemented, including the client server loop, logging, and error handling
Video 1
This just shows the current loop between the client and server, where the client sends a packet, a reset link packet in this case, and the server responds, in this case with a simple acknowledgement.
It also shows how both programs log information about their runs in an assocaited text file. Btw, if you have some sugestions for making this better, please leave a comment. This is just about the simplest way to do logging, so other ideas are appreciated!
Video 2
This shows an example of custom ports, error handling, and more logging. Both the client and server support custom ports (and server adresses in the case of the client) passed in as a launch argument.
You can see when the client trys to connect to a server that either doesn’t exist on the current port, or isn’t active, an error message is displayed into the console and logged in the file.
Alternatively, when both use the same port, the connection succeds, that port is logged as well.
Wrap Up
Lots of stuff to do still, and I am super excited to get started. Thank you to the few of you who have been following development since the beginning, and hello to anyone new!
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.