Results 1 to 6 of 6

Thread: Very strange socket programming problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Very strange socket programming problem

    please help me. I am thinking of getting the messages in the C code itself and passing each message back to the GUI code.
    What is the best possible way of doing this? I need to pass each message received in C code to the GUI so that it gets displayed in the GUI. The C code should keep executing and listening to the socket, as soon as it gets a message it should be sent to the GUI code and the C code should continue listening to the socket.

  2. #2
    Join Date
    Aug 2006
    Posts
    25
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Very strange socket programming problem

    just a wild guess, but can your C code send back the socket descriptor to the GUI code, and then let Qt close the socket?

    then perhaps you can do something like this:
    Qt Code:
    1. int sd = C_CodeFunction();
    2. if(udp->setSocketDescriptor(sd))
    3. {
    4. QObject::connect(udp, SIGNAL(readyRead()), your_obj, SLOT(your_slot()));
    5. }
    To copy to clipboard, switch view to plain text mode 

    or something to that effect.
    Last edited by bhs-ittech; 10th November 2008 at 10:56.

  3. The following user says thank you to bhs-ittech for this useful post:

    montylee (11th November 2008)

  4. #3
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Very strange socket programming problem

    Quote Originally Posted by bhs-ittech View Post
    just a wild guess, but can your C code send back the socket descriptor to the GUI code, and then let Qt close the socket?

    then perhaps you can do something like this:
    Qt Code:
    1. int sd = C_CodeFunction();
    2. if(udp->setSocketDescriptor(sd))
    3. {
    4. QObject::connect(udp, SIGNAL(readyRead()), your_obj, SLOT(your_slot()));
    5. }
    To copy to clipboard, switch view to plain text mode 

    or something to that effect.
    wow!!! it worked I can't believe that your suggestion worked. I just passed the socket descriptor from C code to the Qt code and i am now able to read all messages in the Qt code.

    Thanks a lot for replying and helping me in this issue

    I still have no idea why i was not able to create a new socket and read the messages earlier.

Similar Threads

  1. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  2. A strange problem with QGraphicsSvgItem
    By Justin_W in forum Qt Programming
    Replies: 6
    Last Post: 23rd July 2008, 09:40
  3. Very Strange problem
    By dreamer in forum Qt Programming
    Replies: 1
    Last Post: 30th April 2008, 09:20
  4. Greenphone mini USB socket problem
    By izico in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 25th September 2007, 11:59
  5. Strange Problem with JPEG Support on win XP
    By caligula in forum Installation and Deployment
    Replies: 3
    Last Post: 18th September 2006, 10:36

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
  •  
Qt is a trademark of The Qt Company.