Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Client:: Read(QString filename)
- {
- QFile mfile(filename);
- if(!mfile.open(QFile::ReadOnly | QFile::Text))
- {
- qDebug() << "Could Not Open File For Reading!";
- return;
- }
- QTextStream in(&mfile);
- //QByteArray ba;
- while (!in.atEnd()) {
- line = in.readAll();
- qDebug() << line;
- }
- mfile.close();
- }
- void Client::startTransfer()
- {
- QString mfilename ="/home/ddm/Desktop/client_24.08.12/ENV_1_M2000.csv";
- Read(mfilename);
- QByteArray ba = line.toLocal8Bit();
- c_str2 = ba.data();
- client.write(c_str2,2048);
- }
- mythread.cpp
- void MyThread :: readyRead()
- {
- float array[ROWS][COLS];
- QByteArray Data = socket ->readAll();
- QString str(Data);
- qDebug()<< socketDescriptor <<"Data in:" <<row<<Data;
- QStringList tempCN = str.split("n");
- qDebug()<<"tempCN="<<tempCN;
- for(int i=0;i<40;i++)
- {
- QStringList tempCN1 = tempCN[i].split(",");
- qDebug()<<"tempCN1["<<i<<"]="<<tempCN1;
- array[i][0] = QString(tempCN1[0]).toFloat();
- array[i][1] = QString(tempCN1[1]).toFloat();
- array[i][2] = QString(tempCN1[2]).toFloat();
- array[i][3] = QString(tempCN1[3]).toFloat();
- array[i][4] = QString(tempCN1[4]).toFloat();
- array[i][5] = QString(tempCN1[5]).toFloat();
- }
- for(int i=0;i<40;i++)
- {
- for(int j=0;j<6;j++)
- {
- qDebug()<<"array["<<i<<"]"<<"["<<j<<"]"<<array[i][j];
- }
- }
- row++;
- /* col++*/;
- }
- void MyThread :: disconnected()
- {
- qDebug()<< socketDescriptor <<"Disconnected";
- socket->deleteLater();
- exit(0);
- }
- myserver.cpp
- void MyServer :: StartServer()
- {
- if(!this->listen(QHostAddress::Any,1234))
- {
- qDebug() << "Could not start server";
- }
- else
- {
- qDebug() << "Listening...";
- }
- }
- void MyServer :: incomingConnection(int socketDescriptor)
- {
- qDebug()<<socketDescriptor<<"Connecting...";
- MyThread *thread = new MyThread(socketDescriptor,this);
- connect(thread,SIGNAL(finished()),thread,SLOT(deleteLater()));
- thread ->start();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement