Multi-threading



Greetings everyone:

Here I am with another of my stupid questions: I am currently working on an application whose purpose is to demonstrate an ability to communicate with the credit card processing servers operated by British Petroluem (BP) in this country. One of the things I must do is "listen" for "device requests" issued by their EPS device. All these communications are done via TCP/IP over a local lan.

Since these device requests can arrive on a particular port at any time, I have set up a pthread type thread to establish a listening socket on that port. When this thread's call to accept() returns a good socket I spawn another thread that is a one shot affair to receive the actual request and deal with it. It is in this second thread that I am running into trouble.

What I want to do (for now) is take the actual message arriving from the BP EPS and display it in a Gtk::TextView by inserting it into the Gtk::TextBuffer associated with the view. So, I have made the function used to spawn the second thread a friend of my window class and I make the call to Gtk::TextBuffer::insert in that second thread. Here is where the problems arise. If I do a standard "wait for the main loop" device e.g.

while(Gtk::Main::events_pending())
   Gtk::Main::iteration();

I get the following stderr output:

GLib-ERROR **: file gmain.c: line 1898 (g_main_dispatch): assertion failed: (source) aborting...
Terminated with signal 6 (Aborted)

Can anyone give me a hint as to my error(s) here? I am calling the Gtk::Main methods from a thread twice removed from the one that actually started that instance of Gtk::Main... Perhaps should I use Glib::ThreadPool rather than pthreads?

All comments will be greatly appreciated,

Bob Caryl
begin:vcard
fn:Robert Caryl
n:Caryl;Robert
org:Fiscal Systems, Inc.
adr:;;102 Commerce Circle;Madison;AL;35758;USA
email;internet:bob fis-cal com
title:Senior Software Design Engineer
tel;work:356-772-8920 X108
x-mozilla-html:TRUE
url:http://www.fis-cal.com
version:2.1
end:vcard



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]