LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-26-2008, 06:52 AM   #1
greeklegend
Member
 
Registered: Feb 2006
Location: At a computer
Distribution: Ubuntu 7.04, LFS 6.3 rc1 (living dangerously ;), Windows XP
Posts: 75

Rep: Reputation: 15
Qt asynchronous sockets problem


Hey everybody,
I'm trying to write a simple, four-player card game to play over the network using the QT4 toolkit. I've set up a protocol (client/server) such that I always know when I must do sending and when I must do recieving. Unfortunatly using the sockets system is causing me epic headaches!
The problem is, I don't want to block the GUI by using QTcpSocket::waitForReadyRead(). What I had in mind was using blocking I/O in a thread whenever it was necessary and catching the thread's terminate signal in my main loop...but then I have no way of knowing which socket (player) I just finished sending data to!
Idealy, i'd like to do something like this...

(in the server)
Code:
class MyIOThread : public QThread
{
public:
QTcpSocket* socket;
....other game data....
int result;
void run(); };

void MyIOThread::run(){ some code using data and socket->read(); set this.result; return;}

...ive decided some recieving needs to be done from the client...
MyIOThread* thethread = new MyIOThread;
thethread->socket = some_socket_somewhere;
connect(thethread, SIGNAL(terminate()), this, SLOT(aslot()));

void aslot()
{
do soemthing with MyIOThread_instance_that_I_declared_before.result
}
So is there a way i can find out exactly what instance of a class fired the signal i'm now handling in that slot?
Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in semaphore and how Asynchronous threads eramax Programming 5 07-16-2008 10:52 AM
Program to forward tcp sockets to unix domain sockets mikepol Linux - Networking 0 09-27-2007 09:49 AM
Problem with OpenSSL and sockets alitrix Programming 3 07-08-2005 12:45 PM
problem with sockets... jp-lack Slackware 2 07-06-2005 11:25 AM
Problem with asynchronous notification rajesh_b Programming 2 09-17-2004 07:58 AM


All times are GMT -5. The time now is 12:12 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration