I'm trying to connect to this server. The address is correct and the same with the port.

Qt Code:
  1. #include "MSNSocket.h"
  2. using namespace ShadowMSN;
  3.  
  4. MSNSocket::MSNSocket(const QString& address, quint16 port, QObject* parent)
  5. : QTcpSocket(parent),
  6. m_address(address),
  7. m_port(port)
  8. {
  9. connect(this, SIGNAL(readyRead()),
  10. this, SLOT(receiveCommand()));
  11. connect(this, SIGNAL(connected()),
  12. this, SLOT(msnConnected()));
  13. connect(this, SIGNAL(error(QAbstractSocket::SocketError)),
  14. this, SLOT(errorHandling(QAbstractSocket::SocketError)));
  15. connect(this, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
  16. this, SLOT(stateWasChanged(QAbstractSocket::SocketState)));
  17. m_socket = new QTcpSocket;
  18. this->connectToHost(address, port);
  19. }
  20.  
  21. QString MSNSocket::sendCommand(const QString& command)
  22. {
  23. if(command.isEmpty()) {
  24. return " ";
  25. }
  26.  
  27. m_msnCommand.parseCommand(command.toUtf8());
  28. this->write(m_msnCommand.toString().toUtf8());
  29. return m_msnCommand.toString().toUtf8();
  30. }
  31.  
  32. void MSNSocket::receiveCommand()
  33. {
  34. //if(this->bytesAvailable())
  35. //{
  36. char* data = new char[this->bytesAvailable()];
  37. qDebug() << this->read(data, this->bytesAvailable());
  38. qDebug() << data;
  39. //}
  40. //else
  41. //{
  42. //qDebug() << "No data received";
  43. //}
  44. }
  45.  
  46. void MSNSocket::errorHandling(QAbstractSocket::SocketError error)
  47. {
  48. qDebug() << "Error: " << error;
  49. }
  50.  
  51. void MSNSocket::msnConnected()
  52. {
  53. qDebug() << "Connected";
  54. }
  55.  
  56. void MSNSocket::stateWasChanged(QAbstractSocket::SocketState state){
  57. qDebug() << "New State: " << state;
  58. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. './shadowmsn'
  2. New State: QAbstractSocket::HostLookupState
To copy to clipboard, switch view to plain text mode