After saying 'hello' this post is my second on QT Centre Forum. Anybody quess, that I have problem
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::Parse("192.168.1.5"),40000);
try
{
m_connectionSocket = gcnew Socket(AddressFamily::InterNetwork,SocketType::Stream,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";
}
}
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::Parse("192.168.1.5"),40000);
try
{
m_connectionSocket = gcnew Socket(AddressFamily::InterNetwork,SocketType::Stream,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";
}
}
To copy to clipboard, switch view to plain text mode
And the second - my first steps in network connections in QT:
void trakkermodel::setConnection(){
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);
}
}
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);
}
}
To copy to clipboard, switch view to plain text mode
I get delirium when I see text "Failed to connect inside setConnection"
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.
Bookmarks