Well, both ChatGPT and Grok are mainly “guessing” (these days maybe even a well-educated guess). That never means you can stop reflecting on the result and evaluate for yourself whether the result is provided makes sense. Here – who knows where they got that from.
I would usually first recommend to read the documentation of the packages you want to use and only use LLMs to to work that is “hideous to write but does not require much thinking” – and where you can see that the result should be fine. For best of cases back that up with tests of course.
I think you want to use Sockets from the Standard Library, see Sockets · The Julia Language?
From the large amount of code you posted it is a bit hard to tell what you try to accomplish. Can you maybe first check the linked docks above whether they help and then specify the question more precisely where you need help?