Results 1 to 7 of 7

Thread: client-server how?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Posts
    10
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default client-server how?

    Hello Everybody

    I would like to make a client-server arcitecture with Qt 4.0, using QTcpServer and QTcpSocket. I want one server and several, say 10 clients. I also want to communicate in both directions, sending messages from server to clients (which is easy) and from clients to servers (that's the hard part).
    I tried to do it in the following way. I have a QTcpServer listening on one machine's port. I have several clients on other machines or port. First they all try to connect the server through the given hostname and port using connectToHost(). In the server whenever a new connection arrives I put the result of nextPendingConnection() to a vector containing sockets. Now this way it is easy to send anything to the clients from the server, I simply choose a socket from that vector and than send something on that socket (using QDataStream on the choosen socket, than write).
    However, I can't see how can I send anything from the clients to the server. I use the client's socket to send some data. When data arrives in the server a readyRead() signal is emitted. But how can I know which socket emitted that signal? How can I choose the right socket from my vector? I cannot even send an ID with the client, because for reading that ID the server should first know which client sent that ID. So is there any solution, or my whole arcithecture is wrong this way? If it is wrong, could you sketch some other way.

    ps. I saw that there was many thread about similar questions, but I could not find a satisfying answer anywhere, if You know about one I'm glad if you point to it.

    Thanks for Your answers
    Peter

  2. The following 2 users say thank you to nongentesimus for this useful post:

    siraansa (21st August 2006), sudeepdua (28th November 2006)

Similar Threads

  1. Fix: QT app won't run under Oracle Standard Client install
    By GreyGeek in forum General Discussion
    Replies: 0
    Last Post: 12th May 2006, 18:20
  2. How do I keep the client connection open ?
    By probine in forum Newbie
    Replies: 2
    Last Post: 25th March 2006, 19:06
  3. The server cannot write to the client. Why?
    By probine in forum Newbie
    Replies: 12
    Last Post: 24th March 2006, 17:14
  4. Asynchronous server msg vs synchronous functions
    By nouknouk in forum Qt Programming
    Replies: 9
    Last Post: 2nd February 2006, 17:10
  5. synching client readings to server output
    By OnionRingOfDoom in forum Qt Programming
    Replies: 14
    Last Post: 28th January 2006, 18:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.