PDA

View Full Version : sending Text or binary file over network



Tavit
20th March 2008, 12:05
hi

how can i send text string or a block of binary numbers over a LAN to another computer so that i can receive it there and display the data i send. I tried QSocket but it din't work. Here is the Code :


void transmitter::dothis()
{
QVector<QRadioButton*> rButtonContainer;
rButtonContainer.push_back(radioButton_1);
rButtonContainer.push_back(radioButton_2);
rButtonContainer.push_back(radioButton_3);
rButtonContainer.push_back(radioButton_4);
rButtonContainer.push_back(radioButton_5);
rButtonContainer.push_back(radioButton_6);

QString str;
for(int i=0; i <rButtonContainer.size(); ++i)
{
if(rButtonContainer[i]->isChecked())
{
str+=rButtonContainer[i]->text();
}

QByteArray block = "";
block.append(inputLine->text() );
socket->write(block);
}
}

I have to send the Label of the RadioButton which is checked over the Network to another computer. Which i am not able to. ?? !!

What is the code the receive slot should have to receive and display the data sent from the transmitter. ?? Pls get me out of this prob.

Thank you

codeslicer
21st March 2008, 00:42
There is already an example of this in the Qt4 documentation. Also, QTCPSocket is used in place of QSocket in qt4.

Have a look here: http://doc.trolltech.com/latest/qtcpsocket.html

There are some examples like the Fortune Client. Just modify some parts of it to make them work with your situation.