Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 11-26-2008, 07:52 AM   #1
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)
class MyIOThread : public QThread
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?


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 11:52 AM
Program to forward tcp sockets to unix domain sockets mikepol Linux - Networking 0 09-27-2007 10:49 AM
Problem with OpenSSL and sockets alitrix Programming 3 07-08-2005 01:45 PM
problem with sockets... jp-lack Slackware 2 07-06-2005 12:25 PM
Problem with asynchronous notification rajesh_b Programming 2 09-17-2004 08:58 AM > Forums > Non-*NIX Forums > Programming

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

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