Roy 10,832 / 0 Report Post Posted January 21, 2020 Hey everyone, I just wanted to share a small C program I made that continuously sends A2S_INFO requests to a specified IP and port over the UDP protocol every second. If it doesn't receive a response (i.e. a dropped packet), it will print out the current date. You may also specify a timeout for the request if needed (default is 1). I am using this tool to debug our game servers on our Anycast network using Linux VMs, etc. I'm still pretty new to C programming. Therefore, I'm sure there are ways I could optimize this code. I plan to add more functionality which includes getting the timing of the request => response (AKA the ping) along with parsing the response data itself. GitLab Repository If you find anything that can be improved on, please let me know! Thanks! Share this post Link to post Share on other sites More sharing options...
_Rocket_ 656 / 8,277 Report Post Posted January 23, 2020 · Hidden Hidden ah yes very elegant and clean code. There's a few small formatting changes I'd personally make, but programmers tend to differ in how they structure their code. What really matters is the code itself. And yes miboi, that's clean shet. I will always love the freedom you have in if statements or while loops. It's something languages that Java and others just miss out on. if((err = function(args)) > 0) With that one line alone, you were able to assign a value to the err variable so the if statement can use it if the result is greater than 0. A bad boi would do this: err = function(args); if(err > 0) Dirty code. Don't like it. Not elegant. Get outta here with that. Actually, it could be worse. if(function(args) > 0) { err = function(args); } Just looking at that hurts my soul D; Case and point, very dank code. I write programs and stuff. If you need to contact me, here is my discord tag: Dustin#6688 I am a busy person. So responses may be delayed. Share this post Link to post
Roy 10,832 / 0 Report Post Posted January 23, 2020 3 hours ago, _Rocket_ said: ah yes very elegant and clean code. There's a few small formatting changes I'd personally make, but programmers tend to differ in how they structure their code. What really matters is the code itself. And yes miboi, that's clean shet. I will always love the freedom you have in if statements or while loops. It's something languages that Java and others just miss out on. if((err = function(args)) > 0) With that one line alone, you were able to assign a value to the err variable so the if statement can use it if the result is greater than 0. A bad boi would do this: err = function(args); if(err > 0) Dirty code. Don't like it. Not elegant. Get outta here with that. Actually, it could be worse. if(function(args) > 0) { err = function(args); } Just looking at that hurts my soul D; Case and point, very dank code. I made some changes yesterday (e.g. cleaned up code and added an interval argument). I've been looking into a new function called nanosleep() as well and plan to make the interval argument accept float values. I will push the new code to GitLab later today! Thank you. Share this post Link to post Share on other sites More sharing options...