I am beginning a new (game) project, and I'm using both Allegro and network communication for the first time. The documentation of Allegro is easy and complete so I have a good time using it, but I still have just notions of how a network works (I am still learning about what sockets are exactly).
I am now at the point where I need the game client to retrieve data such as position of players sent from a server.
So, as in my main loop I am waiting for an event, using :
and as this function "freezes" the program, I can't call such things as 'recv' or 'recvfrom' to process the data I should receive,
I imagined I could create an user event which would be emitted whenever data was retrieved.
Sadly, I couldn't find a similar question or an example about events and network, so I am referring to your wisdom.
My questions are :
- Is it the "proper way" to handle data communication over a network ?
- if not, what method should I use ?
- if yes, how do I have to "emit" my event ? (do I have to use multithreading (which I have never used either) ? Is there a way to "overload" the al_wait_for_event function ?)
I apologize if the terms I used aren't exact (I hope it's still understandable).
Thanks in advance for your answers.
edit : I omitted to mention I wish to use only C language (so no objects).