Results 1 to 1 of 1

Thread: TCP IP Client : Host Not found : Permission Denied

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    32
    Qt products
    Qt4
    Platforms
    Windows

    Default TCP IP Client : Host Not found : Permission Denied

    Hi All,

    I am new to QT and Symbian, and to be honest i have spent a week trying to figure out what is wrong here in my TCP IP Client that runs on Nokia E52, with no luck.

    Every time i try to connect to Server using domain name i get error : "Host Not Found"
    Every time is use IP addess is get "Permission Denied"

    I have tested the Server using SIC Ftp for Symbian and Ftp for Android they all can connect to server using same domain name and the port no, therefore i am sure i have something wrong in my client code. Any help would be greatly appreciated.

    Code:-

    qmake Code:
    1. //TCP_Client.pro
    2. //---------
    3. QT += core gui
    4. QT += network
    5.  
    6.  
    7. TARGET = TCP_Client
    8.  
    9. TEMPLATE = app
    10.  
    11.  
    12. SOURCES += main.cpp\
    13. tcp_client.cpp
    14.  
    15. HEADERS += tcp_client.h
    16.  
    17. FORMS += tcp_client.ui
    18.  
    19. CONFIG += mobility
    20. MOBILITY = bearer
    21.  
    22. symbian {
    23. TARGET.UID3 = 0xe184b214
    24. TARGET.CAPABILITY += "NetworkServies ReadUserData WriteUserData"
    25. TARGET.EPOCSTACKSIZE = 0x14000
    26. TARGET.EPOCHEAPSIZE = 0x020000 0x800000
    27. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //tcp_client.h
    2. //-------
    3. #ifndef TCP_CLIENT_H
    4. #define TCP_CLIENT_H
    5.  
    6. #include <QMainWindow>
    7. #include <QTcpSocket>
    8. #include <QtNetwork>
    9.  
    10. namespace Ui {
    11. class TCP_Client;
    12. }
    13.  
    14. class TCP_Client : public QMainWindow
    15. {
    16. Q_OBJECT
    17.  
    18. public:
    19. explicit TCP_Client(QWidget *parent = 0);
    20. ~TCP_Client();
    21.  
    22. private:
    23. Ui::TCP_Client *ui;
    24. QTcpSocket *tcpSocket;
    25. quint16 blockSize;
    26.  
    27. private slots:
    28. void requestNewFortune();
    29. void readFortune();
    30. void displayError(QAbstractSocket::SocketError socketError);
    31. };
    32.  
    33. #endif // TCP_CLIENT_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //tcp_client.cpp
    2. //---------
    3. #include "tcp_client.h"
    4. #include "ui_tcp_client.h"
    5.  
    6. #include<QtGui>
    7. #include<QtNetwork>
    8.  
    9. TCP_Client::TCP_Client(QWidget *parent) : QMainWindow(parent), ui(new Ui::TCP_Client)
    10. {
    11. ui->setupUi(this);
    12.  
    13. tcpSocket = new QTcpSocket(this);
    14. connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(requestNewFortune()));
    15. connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
    16. }
    17.  
    18. TCP_Client::~TCP_Client()
    19. {
    20. delete ui;
    21. }
    22.  
    23. void TCP_Client::requestNewFortune()
    24. {
    25. ui->textEdit->clear();
    26. ui->textEdit->append("Connecting to " + ui->lineEdit_1->text() + " Port No. " + ui->lineEdit_2->text());
    27.  
    28. tcpSocket->connectToHost(ui->lineEdit_1->text(), ui->lineEdit_2->text().toInt());
    29. if (tcpSocket->waitForConnected(-1))
    30. ui->textEdit->append("Connected!");
    31. }
    32.  
    33.  
    34. void TCP_Client::displayError(QAbstractSocket::SocketError socketError)
    35. {
    36. switch (socketError)
    37. {
    38. case QAbstractSocket::RemoteHostClosedError:
    39. ui->textEdit->append("The remote host closed the connection.");
    40. break;
    41. case QAbstractSocket::HostNotFoundError:
    42. ui->textEdit->append("The host was not found.");
    43. break;
    44. case QAbstractSocket::ConnectionRefusedError:
    45. ui->textEdit->append("The connection was refused by the peer.");
    46. break;
    47. default:
    48. ui->textEdit->append( tr("TCP_Client, the following error occured: %1").arg(tcpSocket->errorString()));
    49. break;
    50. }
    51. }
    52.  
    53. void TCP_Client::readFortune()
    54. {
    55.  
    56. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //main.cpp
    2. //--------
    3. #include <QtGui/QApplication>
    4. #include "tcp_client.h"
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9. TCP_Client w;
    10. #if defined(Q_WS_S60)
    11. w.showMaximized();
    12. #else
    13. w.show();
    14. #endif
    15.  
    16. return a.exec();
    17. }
    To copy to clipboard, switch view to plain text mode 

    //tcp_client.ui
    xml Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <ui version="4.0">
    3. <class>TCP_Client</class>
    4. <widget class="QMainWindow" name="TCP_Client">
    5. <property name="geometry">
    6. <rect>
    7. <x>0</x>
    8. <y>0</y>
    9. <width>230</width>
    10. <height>239</height>
    11. </rect>
    12. </property>
    13. <property name="windowTitle">
    14. <string>TCP_Client</string>
    15. </property>
    16. <widget class="QWidget" name="centralWidget">
    17. <widget class="QPushButton" name="pushButton">
    18. <property name="geometry">
    19. <rect>
    20. <x>10</x>
    21. <y>54</y>
    22. <width>211</width>
    23. <height>23</height>
    24. </rect>
    25. </property>
    26. <property name="text">
    27. <string>Connect and Send Message</string>
    28. </property>
    29. </widget>
    30. <widget class="QTextEdit" name="textEdit">
    31. <property name="geometry">
    32. <rect>
    33. <x>10</x>
    34. <y>80</y>
    35. <width>211</width>
    36. <height>151</height>
    37. </rect>
    38. </property>
    39. </widget>
    40. <widget class="QLineEdit" name="lineEdit_1">
    41. <property name="geometry">
    42. <rect>
    43. <x>10</x>
    44. <y>10</y>
    45. <width>131</width>
    46. <height>20</height>
    47. </rect>
    48. </property>
    49. <property name="text">
    50. <string>xxxxxx.co.uk</string>
    51. </property>
    52. </widget>
    53. <widget class="QLineEdit" name="lineEdit_2">
    54. <property name="geometry">
    55. <rect>
    56. <x>150</x>
    57. <y>10</y>
    58. <width>71</width>
    59. <height>20</height>
    60. </rect>
    61. </property>
    62. <property name="text">
    63. <string>12345</string>
    64. </property>
    65. </widget>
    66. <widget class="QLineEdit" name="lineEdit_3">
    67. <property name="geometry">
    68. <rect>
    69. <x>10</x>
    70. <y>32</y>
    71. <width>211</width>
    72. <height>20</height>
    73. </rect>
    74. </property>
    75. <property name="text">
    76. <string>Hello World TCP_Client</string>
    77. </property>
    78. </widget>
    79. </widget>
    80. </widget>
    81. <layoutdefault spacing="6" margin="11"/>
    82. <resources/>
    83. <connections/>
    84. </ui>
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 19th January 2011 at 15:13. Reason: missing [code] tags

Similar Threads

  1. Permission denied
    By Frosh in forum Newbie
    Replies: 3
    Last Post: 1st October 2009, 06:46
  2. Permission denied
    By lixo1 in forum Qt Tools
    Replies: 4
    Last Post: 27th March 2009, 09:01
  3. exe permission denied
    By phillip_Qt in forum Qt Programming
    Replies: 1
    Last Post: 30th October 2007, 07:47
  4. Permission denied
    By thomasjoy in forum Qt Programming
    Replies: 1
    Last Post: 17th October 2007, 20:37
  5. QFtp and Permission Denied
    By J-jayz-Z in forum Qt Programming
    Replies: 2
    Last Post: 22nd August 2007, 16:15

Tags for this Thread

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.