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. Tcp socket problem

Tcp socket problem

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 3.4k 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.
  • A Offline
    A Offline
    ahura_24
    wrote on last edited by
    #1

    hi every body . i created one tcp server . this is my code
    @
    class Server : public QObject
    {
    Q_OBJECT
    public:
    explicit Server(QObject *parent = 0);

    private slots:
    void acceptConnection();
    void startRead();

    private:
    QTcpServer server;
    QTcpSocket *client;
    };
    @

    @
    Server::Server(QObject *parent) :
    QObject(parent)
    {
    connect(&server, SIGNAL(newConnection()), this, SLOT(acceptConnection()));

    server.listen(QHostAddress::Any, 9599);
    

    }

    void Server::acceptConnection()
    {
    client = server.nextPendingConnection();
    connect(client, SIGNAL(readyRead()), this, SLOT(startRead()));
    }

    void Server::startRead()
    {
    QByteArray array;

    array = client->readAll();
    qDebug() << array;
    

    }
    @

    start server and "telnet" to it but doesnt work :( server doesnt take new tcp server and telnet failed :( please help me tnx alot

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      You can use the "Fortune Server":http://qt-project.org/doc/qt-5.0/qtnetwork/fortuneserver.html and "Fortune Client":http://qt-project.org/doc/qt-5.0/qtnetwork/fortuneclient.htmlt to start off

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ahura_24
        wrote on last edited by
        #3

        i ran them but doesnt work :-??

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          That would be very strange. If you have a firewall and/or anti-virus running they might prevent the connection. I was not running the Qt5 versions, since I do not use Qt5, but the Qt4.8.4 I have tested not too long ago. They did work like a charm.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ahura_24
            wrote on last edited by
            #5

            yes i guess and i was turned off firewall and anti virus but doesnt work :( i has Windows 7 64-bit ! telnet to Forture server failed !

            1 Reply Last reply
            0
            • K Offline
              K Offline
              koahnig
              wrote on last edited by
              #6

              [quote author="ahura_24" date="1366611993"]yes i guess and i was turned off firewall and anti virus but doesnt work :( i has Windows 7 64-bit ! telnet to Forture server failed ![/quote]
              May be you should test with the FortuneClient against the FortuneServer first.
              TelNet is no longer shipped with Windows 7. So who knows which incompatibility you are running into.

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              0
              • A Offline
                A Offline
                ahura_24
                wrote on last edited by
                #7

                i actived telnet client in windows 7 !! first i ran fortuneServer and then ran fClient and put the port in client and then click on "get fortune" !! nothing occure and client takes timeout error

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  koahnig
                  wrote on last edited by
                  #8

                  [quote author="ahura_24" date="1366614623"]i actived telnet client in windows 7 !! first i ran fortuneServer and then ran fClient and put the port in client and then click on "get fortune" !! nothing occure and client takes timeout error[/quote]
                  That sounds very strange. I am using Windows 7 64 bit as well and it worked. The only recommendation I can give is checkout the firewall and antivirus program, which you have apparently done already.

                  Vote the answer(s) that helped you to solve your issue(s)

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    ahura_24
                    wrote on last edited by
                    #9

                    i check of them !! i was written one tcp server/client with c++ and test them !! work correctly !! the qt library doesnt work !! my above code is worng ? please test it .
                    i test qt examples just (broadcast reciever and sender) work corectly !

                    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