bug-commoncpp
[Top][All Lists]
Advanced

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

problems with threading in cc++ v1.9.1


From: Piotr Esden-Tempski
Subject: problems with threading in cc++ v1.9.1
Date: Thu, 22 Nov 2001 20:32:37 +0100
User-agent: Mutt/1.3.23i

Hi all,

I would like to use CommonC++ for my upcoming project but I have some
problems with it. 
I tryed to start with the demo programs all of them work properly beside
on the tcp service. 
In the form it is contained in the 1.9.1 release and also in the CVS it
compiles but when I want to start it it only brings upt he message
"machine is localhost" and that's it. It seems that one can connect with
telnet cause telnet is opening but when you want to send something you
see no reaction. The tcpserver is not telling that it has accepted a
connection or started The ChatterThread nothing.

I have read through the source of tcpservice and realized that you are
using a semaphore to tell the ChatterThread to start. As I have
rewritten it so that it uses the Start() function it worked. Here two
sample codes:

The not working one :


--thread.cpp--begin--
#include <thread.h>
#include <iostream>
     
using namespace ost;
     
class testthread : public virtual Thread {
        public:
                void Run () { cout << "testthread running!!!" << endl; }
                testthread(Semaphore * sem) : Thread (sem) { cout << 
"testthread created" << endl; }
     };

int main(){
        Semaphore sem[1];
        testthread *mythread;

        mythread = new testthread(sem);

        sem->Post();

        return 0;
}
--thread.cpp--end--

and the working one:

--thread.cpp--begin--
#include <thread.h>
#include <iostream>
     
using namespace ost;
     
class testthread : public virtual Thread {
        public:
                void Run () { cout << "testthread running!!!" << endl; }
                testthread() : Thread () { cout << "testthread created" << 
endl; }
     };

int main(){
        testthread *mythread;

        mythread = new testthread();

        mythread->Start();

        return 0;
}
--thread.cpp--end--

Ok that would be this... as you can see the problem with the semaphore
can be worked around.

I changed this in tcpservice and could connect with telnet and all
worked correctly but as I wanted to connect with second telnet I got the
same problem as before and telnet connected and has not been accepted.
I have not found a solution for that problem till now. 

I currently use debian unstable with gcc version 2.95.4 20011006 (Debian
prerelease) and libc-2.2.4 with kernel 2.4.12 SMP. 

I hope that these informations are usable and you can fix the bug or
tell me what I have done wrong.

cheers Piotr


-- 
bChat2: http://apollo.bingo-ev.de                       ___  ___  ___  _  _
bChat: http://bchat.bingo-ev.de                        | _ || _ || __|| |//
ROCK LINUX: www.rocklinux.org                          ||_|||| ||||   |  /
-Born to run kill -9 win                               |  _|||_||||__ |  \
-"Ignorance is bliss." (Matrix)                        ||\\ |_LINUX__||_|\\
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GIT/CS/CC/ED/P d-(--) s+:- a? c++++ U/S++++ P+++(++++) L++++ E---
W+++ N-(+) o? K? w/--- !O !M V-- PS++@ PE Y+ PGP@ !t !5 X+++ R tv-- b+
DI--- D+ G++ e h!@ r- y+
------END GEEK CODE BLOCK------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]