randomizw

android port

git-svn-id: svn://db.shs.com.ru/pip@39 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2015-03-23 08:49:21 +00:00
parent f89764d6bc
commit cef64a9b80
10 changed files with 40 additions and 16 deletions

View File

@@ -454,7 +454,7 @@ bool PIEthernet::listen(bool threaded) {
return true;
}
//#include <QDebug>
int PIEthernet::read(void * read_to, int max_size) {
//cout << "read " << sock << endl;
if (sock == -1) init();
@@ -486,8 +486,10 @@ int PIEthernet::read(void * read_to, int max_size) {
PRIVATE->addr_.sin_len = sizeof(PRIVATE->addr_);
#endif
//piCoutObj << "connect to " << ip_ << ":" << port_ << "...";
connected_ = (::connect(sock, (sockaddr * )&PRIVATE->addr_, sizeof(PRIVATE->addr_)) == 0);
//qDebug() << "connect to " << ip_.data() << ":" << port_ << sock << PRIVATE->addr_.sin_addr.s_addr << "...";
connected_ = (::connect(sock, (sockaddr * )&(PRIVATE->addr_), sizeof(PRIVATE->addr_)) == 0);
//piCoutObj << "connect to " << ip_ << ":" << port_ << connected_;
//qDebug() << "connect to " << ip_.data() << ":" << port_ << connected_;
if (!connected_)
piCoutObj << "Can`t connect to " << ip_ << ":" << port_ << ", " << ethErrorString();
opened_ = connected_;
@@ -497,13 +499,16 @@ int PIEthernet::read(void * read_to, int max_size) {
} else
piMSleep(10);
//piCout << "connected to" << path();
//qDebug() << "connected to" << path().data();
}
if (!connected_) return -1;
errorClear();
rs = ethRecv(sock, read_to, max_size);
//piCoutObj << "readed" << rs;
//qDebug() << "readed" << rs;
if (rs <= 0) {
lerr = ethErrorCore();
//qDebug() << "readed error" << errorString().data();
#ifdef WINDOWS
if (lerr == WSAEWOULDBLOCK || /*lerr == NO_ERROR ||*/ lerr == WSAETIMEDOUT) {
#else
@@ -521,6 +526,7 @@ int PIEthernet::read(void * read_to, int max_size) {
//piCoutObj << "eth" << ip_ << "disconnected";
}
if (rs > 0) received(read_to, rs);
//qDebug() << "return from read" << rs;
return rs;
case UDP:
memset(&PRIVATE->raddr_, 0, sizeof(PRIVATE->raddr_));