PDA

View Full Version : Why i can't get the file.



stylev
28th September 2006, 11:56
//client.cpp
//..........................
connect(senderButton, SIGNAL(clicked()), this, SLOT(sendMessageSlot()));
void Send::sendMessageSlot()
{

QDataStream out(client);
QFileInfo info(file->fileName());
out << info.fileName() << currentSize;

while(!file->atEnd())
{
char schar[2048];
if (currentSize >= 2048)
{
file->read(schar, 2048);
client->write(schar, 2048);
currentSize-=2048;
}
else if(currentSize < 2048)
{
file->read(schar, currentSize);
client->write(schar, currentSize);
break;
}
}
file->close();
}
------------------------------------------------------------------------------------
//server.cpp
//...........
connect(server, SIGNAL(readyRead()), this, SLOT(newMessageSlot()));
void Receive::newMessageSlot()
{
if (boo_new)
{
QDataStream in(server);
in >> name >> allSize;
boo_new = false;
}

file = new QFile(QString("C:\\%1").arg(name), this);
file->open(QIODevice::WriteOnly |QIODevice::Append);


if (server->isReadable())
{
quint64 size = server->bytesAvailable();
char buf[size];
server->read(buf, size);
file->write(buf, size);
readSize += size;

}
file->close();
delete file;
if (readSize == allSize)
{
QMessageBox::warning(this, "ok", QString::fromLocal8Bit("over"));
return;
}
}

----------------------------------------------------------
I am from in china, my English is very ppor, pardon me!
compile and run it.
i can get file in server from client send in local area network
buf i can't get file in server from client send in internet...

why ?
i did't understand English, please reply some correct codes...

thank very very much............

//if you want to make china friends, please add me
//janlex@msn.com

e8johan
28th September 2006, 13:53
Could be a firewall issue.

stylev
28th September 2006, 18:53
if in internet, i can just only get a litte bytes..

i was make sure that it has problem without firewall

high_flyer
28th September 2006, 19:45
maybe a timeout issue then...

stylev
29th September 2006, 07:42
what can i do?

who can tell me that the problem...

wysota
29th September 2006, 09:16
Do example network programs bundled with Qt work fine for you over the net?