I'm still making progress on the wifi protocol, however it is proving difficult to make it reliable and fast at the same time.
For starters it is a frustrating protocol to implement. When receiving a response from a message we sometimes get nothing in return, sometimes an ok, sometimes an ok with a $, and occasionally an error code. Wifi usually returns less than the serial connection. Some queries return json, some return raw values and one (query=a) returns a series of returns that may be terminated with a $ and may not. All of that makes it difficult to know exactly how many bytes should be returned, and in turn leads to unnecessary delays.
On top of that the wifi protocol was written in an inefficient way. It takes many cycles for it to respond to any request, even more cycles just to handle the initial connection. And when it does communicate it sends way too many packets of data. Network packets work best when you pack as much data as possible into a single packet. However this protocol makes a new packet for every line of data, in the query=a case that means 30 or so packets for what could have taken only one.
Finally the wifi protocol is particularly bad at recovering from any error. If I send a request too fast it locks up and refuses to take any other message, however there is no clear indicator of when the system is ready to receive a message.
In short any query to wifi is currently taking about a second to complete, and connecting to the machine takes up to 5 seconds. Both of those should be in the tens of milliseconds even in its current form, something is really slowing things down. I don't think this is a byproduct of my code, the XYZWare application is just as sluggish over wifi. It does give me hope that a serial to wifi bridge can be made that is much more efficient then there implementation.
Finally the socket library on windows is very complex and frankly a bit overwhelming. There are three major ways you can use the library (and a few windows specific variants on the third way) and I have currently tried two of the three ways, both have proven to be unreliable. I'm looking into writing something using the third variant, but that will require a complete refactoring of how I communicate with the printer. That may end up being a good thing in the end, but it will add a lot of complexity.
In short, I'm frustrated and needed to vent a bit, however I am making progress.