PDA

View Full Version : QTcpSocket not connecting to ARM tcp serwer



zienek
21st October 2009, 22:21
After saying 'hello' this post is my second on QT Centre Forum. Anybody quess, that I have problem :rolleyes:

So. I have a project to do. My project is related to sound aquisition and processing. I decided to gather sound via ARM processor send samples through Ethernet to x86 computer and there to process it.

Part related to ARM is done. Moreover some part of x86 is drafted in MS Visual Studio 2005. And is working fine (as you can see at adc.jpg file).

Problem raised when I tried to rewrite connection into QT.
Below Windows working code:


System::Void m_buttonConnect_Click(System::Object^ sender, System::EventArgs^ e)
{
if (m_connectionSocket==nullptr || !m_connectionSocket->Connected)
{
System::Net::IPEndPoint ^ endpoint = gcnew System::Net::IPEndPoint(System::Net::IPAddress::Pa rse("192.168.1.5"),40000);

try
{
m_connectionSocket = gcnew Socket(AddressFamily::InterNetwork,SocketType::Str eam,ProtocolType::Tcp);
m_connectionSocket->Connect(endpoint);
}
catch (Exception ^ e)
{
System::Windows::Forms::MessageBox::Show(e->Message,"Connecting error",MessageBoxButtons::OK,MessageBoxIcon::Error);
return;
}

m_labelStatus->Text = "Connected";
}
}

And the second - my first steps in network connections in QT:


void trakkermodel::setConnection(){
QTcpSocket qsoket;

qsoket.connectToHost("192.168.1.5",40000);

if (qsoket.isOpen()){
qDebug("qsoket is open");
}

if (qsoket.waitForConnected(5000)==false){
emit sigSetStatus("Failed to connect qsoket",2000);
qDebug("Failed to connect inside setConnection\n");
//printf("Failed to connect\n");
}else{
emit sigSetStatus("qsoket connection estabilished sucessfully",2000);
}
}

I get delirium when I see text "Failed to connect inside setConnection" :crying:

Moreover - in QT Creator I cannot take any glimpse on qsoket's values. Is it correct?

On request I will paste next codes, but I wont to generate noise. So if you find such step useful - please write.

zienek
23rd October 2009, 18:23
Problem solved.

In windows i had default address 192.168.1.1. In linux IPv4 was not set at all. After setting proper address of eth0 QTcpSocket connects to host.

I generate problems which are not trivial ;)