M
Mikael S. H.
Hello comp.lang.c++.
My friend and I are trying to make a simple IRC client. It'll work
mostly like irssi, by having "signals", which you can "tie" a function
to. These functions get executed whenever a certain event happens, such
as "message received" or "got opped".
The problem is, that I haven't been able to do this, *and* add
"timeouts", which would execute a function after a certain piece of
time. Whenever I'm trying to read from the socket, it stops program
execution if no message is to be received, and only continues when it does.
I've thought about making a threaded version, so another process will
constantly read from the socket, putting any messages there are into a
variable, which the main program would read. This would mean, that you
would simply get NULL from the socket_read() function, if there is no
message.
That is not an easy task, I found out.
I have never seen this much frightening documentation about a subject in
my life. I have tried to read into Mutex's, threadsafe functions and
void pointer casting of arguments, but it all fails miserably to even
make the slightest sense.
Is threading the best solution to this problem?
How would some code look, just in general?
Thank you all in advance,
Mikael S. Høilund.
My friend and I are trying to make a simple IRC client. It'll work
mostly like irssi, by having "signals", which you can "tie" a function
to. These functions get executed whenever a certain event happens, such
as "message received" or "got opped".
The problem is, that I haven't been able to do this, *and* add
"timeouts", which would execute a function after a certain piece of
time. Whenever I'm trying to read from the socket, it stops program
execution if no message is to be received, and only continues when it does.
I've thought about making a threaded version, so another process will
constantly read from the socket, putting any messages there are into a
variable, which the main program would read. This would mean, that you
would simply get NULL from the socket_read() function, if there is no
message.
That is not an easy task, I found out.
I have never seen this much frightening documentation about a subject in
my life. I have tried to read into Mutex's, threadsafe functions and
void pointer casting of arguments, but it all fails miserably to even
make the slightest sense.
Is threading the best solution to this problem?
How would some code look, just in general?
Thank you all in advance,
Mikael S. Høilund.