I've been working on a asynchronous network library meant to be used with the Teamspeak 3 remote server query. It will serve various purposes but for now, it's only meant to parse messages, send an event when a message is received, and provide a method of sending messages in a convenient manner. There are a few problems.
1. I'm not sure how to handle errors in an asyncronous environment. Any suggestions on this would be lovely. The environment will optionally use threads but they are not required.
2. I have four functions (that deal with actual networking):
1 2 3 4 5 6 7 8
|
extern "C" {
void* ts3qclient_initialize(struct ts3qsEvent_t* events);
int ts3qclient_connect(void* handle, char const* server, unsigned short port);
void ts3qclient_quit(void* handle);
void ts3qclient_sendCommand(void* handle, char const* command);
}
|
The initialize function will be provided all the events you wish to participate in. Unfortunately, the structure you pass must obviously be initialized to nothing if you don't plan on using all events.
The connect function will obviously connect. Password and authentication is sent via sendCommand which is why its not handled here.
A serious issue is of course the lack of error handling and the confusing return codes. I'm open for suggestions on what would be most useful to return. Please take note that in an asynchronous environment, you can't really have networking functions return error codes since the result of the asynchronous action hasn't actually been accomplished yet!
Summary
I really need some feedback. Please keep it constructive. The interface is in C because it would be sinful to complicate ABI over four functions. I posted in lounge simply because it has more to do with design than code.