Dear Kjell and list , Thank you so mush, i wake up now,I wrote the following function as a signal: /////////////////////////////////////////////////// bool NetworkSocket::isDataReady() { void *buffer; sockaddr_in from; socklen_t fromLength = sizeof( from );
if (::recvfrom(this->socketFD,buffer,FRAMEBUFFER + 6, 0, (sockaddr *)&this->getSocketAddressStructureOfServer(), &fromLength ) == -1) { if (errno == EAGAIN || errno == EWOULDBLOCK) return false; } return true; } ///////////////////////////////////////////////// When in blocking mode data is ready it can notify me that i can read socket... Then i wrote a function as slot: /////////////////////////////////////////////////// int NetworkSocket::readDatagrams(unsigned char *buffer, string &srcAddress, unsigned short int & srcPort) { unsigned int maximumPacketSize = FRAMEBUFFER + 6; int returnValue ; sockaddr_in from; socklen_t fromLength = sizeof( from ); int receivedBytes; fromLength = sizeof(this->getSocketAddressStructureOfServer()); receivedBytes = recvfrom( this->socketFD, buffer, maximumPacketSize, 0, (sockaddr *)&this->getSocketAddressStructureOfServer(), &fromLength ); returnValue = receivedBytes; if ( receivedBytes <= 0 ) returnValue = -1; srcAddress = inet_ntoa(this->getSocketAddressStructureOfServer().sin_addr); srcPort = ntohs( ( unsigned short int)this->getSocketAddressStructureOfServer().sin_port ); return returnValue; } //////////////////////////////////////////////////////// Above functions work fine, Kjell helped and i debug my code that wrote in asleep, i define the following 2 lines in class body: ///////////////////////////// sigc::signal<bool> ready; void run(); /////////////////////////// the i wrote following code in constructor: ////////////////////////// this->ready.connect(sigc::mem_fun(*this,&NetworkSocket::createThread)); ///////////////////////////////////////// Question: But i don't relate my signal (isDataReady()) to createThread Thank you for attention predictable.... --mohsen On Wed, 2012-08-01 at 22:36 +0430, Mohsen Pahlevanzadeh wrote: > Dear Kjell, > At first Thank you for your reply, > You woke up me,I was asleep and code, thank you, i need to rest... > > --mohsen > On Wed, 2012-08-01 at 18:53 +0200, Kjell Ahlstedt wrote: > > 2012-08-01 16:45, Mohsen Pahlevanzadeh skrev: > > > Dear all, > > > > > > I have 2 question: a. about the libsigc b. about (this) word and typeof > > > or decltype > > > I have NetworkSocket class and coded in main() func such as the > > > following: > > > /////////////////////////////////// > > > NetworkSocket *oo = new NetworkSocket(); > > > oo->ready.connect(sigc::ptr_fun(&NetworkSocket::createThread)); > > > oo->run(); > > > /////////////////////////////////////// > > > Above code get the following error: > > > ///////////////// > > > error: no matching function for call to ‘ptr_fun(bool > > > (NetworkSocket::*)())’ > > > //////////////// > > > > > > When i comment the above code , and put the following code in constructor > > > : > > > ////////////////////////////////////// > > > typeof(this) sig = new NetworkSocket(); > > > sig->ready.connect(sigc::ptr_fun(createThread)); > > > this->run(); > > > //////////////////////////////////////// > > > I get the following error: > > > //////////////////////////////// > > > error: no matching function for call to ‘ptr_fun(<unresolved overloaded > > > function type>)’ > > > //////////////////////////////// > > > So , i think g++ can't understand type of this reserverd word.And i don't > > > understand no match call function. > > > > > > Yours, > > > Mohsen > > > > > Is NetworkSocket::createThread() a static member function? If it's not > > static, you must use sigc::mem_fun() instead of sigc::ptr_fun(). > > > > NetworkSocket *oo = new NetworkSocket(); > > oo->ready.connect(sigc::mem_fun(*oo, &NetworkSocket::createThread)); > > oo->run(); > > > > or > > > > typeof(this) sig = new NetworkSocket(); > > sig->ready.connect(sigc::mem_fun(*this, &NetworkSocket::createThread)); > > // or mem_fun(*sig...? > > this->run(); > > > > but here you have 2 NetworkSocket objects, *this and *sig. Is that what > > you want? Should it be > > > > ready.connect(sigc::mem_fun(*this, &NetworkSocket::createThread)); > > this->run(); > > > > What makes you suspect that g++ does not understand typeof(this)? You > > don't mention any error message that contains 'typeof'. > > > > _______________________________________________ > libsigc-list mailing list > libsigc-list@gnome.org > https://mail.gnome.org/mailman/listinfo/libsigc-list
signature.asc
Description: This is a digitally signed message part
_______________________________________________ libsigc-list mailing list libsigc-list@gnome.org https://mail.gnome.org/mailman/listinfo/libsigc-list