Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Multiple sockets Read and Write.
QtWS25 Last Chance

Multiple sockets Read and Write.

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vsnmtej
    wrote on last edited by
    #1

    I want to open two sockets and Read data from one socket and write data on the other in accordance with the read data.
    Scenario Read data from socket 1 and write some data on to Socket 2 in parallel and wait for ack from socket 2 and then again write some data on socket 2 and again wait for acknowledgement. During this process socket1 should continue reading data.

    I am new to Qt .Do i need to use Threads. Please let me know how can i proceed

    @Client::Client(QObject* parent): QObject(parent)
    {
    connect(&client, SIGNAL(connected()),
    this, SLOT(startTransfer()));
    connect(&tcpsocket, SIGNAL(connected()),
    this, SLOT(startTransfer1()));

    connect(&client, SIGNAL(readyRead()),
    this, SLOT(readDataFromConnection()));
    connect(&tcpsocket, SIGNAL(readyRead()),
    this, SLOT(read_ackfromTagbc()));
    //connect(&client,SIGNAL(),this,SLOT(startTransfer()));
    }@

    when i do it in the above way the Qt crashes.

    1 Reply Last reply
    0
    • mrdebugM Offline
      mrdebugM Offline
      mrdebug
      wrote on last edited by
      #2

      If you want to use thread you haven't to use events. You can use functions like ReadyRead, waitforbyteswritten...

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        Theses connect statements should not lead to crashes. Where does it happen exactly ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • IamSumitI Offline
          IamSumitI Offline
          IamSumit
          wrote on last edited by
          #4

          Hello vsnmtej
          I think your program crashed because You did not allocate memory to "&client" and "&tcpsocket" using "new " in constructor.
          Most of the time Crashes happens Whenever you donot allocate memory to the pointer variables using new operator and you use them directly.
          Here in given code ,i can't see the allocation to socket variables.

          Be Cute

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved