Changeset 169


Ignore:
Timestamp:
Mar 9, 2016, 11:51:26 PM (6 years ago)
Author:
ertl-honda
Message:

サーバーからクローズされた場合にavailable()にfalseを返すよう変更

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/Client_ESP8266.h

    r144 r169  
    6969        }
    7070    };
    71     int available(){return (bufferlen > 0 || dataAvailable());};
     71    int available(){
     72        if (bufferlen > 0) {
     73            return 1;
     74        }
     75        if (dataAvailable()) {
     76            bufferlen = recv(buffer, ESP8266CLIENT_BUFFER_LEN);
     77            pbuffer = buffer;
     78            //In case of that data is aviable but it is not valid data(not +IPD,...),
     79            //connection is closed by server.(send "CLOSED")
     80            if(bufferlen == 0){
     81                _connected = 0;
     82                releaseTCP();
     83                return 0;
     84            }
     85            return 1;
     86        }
     87        return 0;
     88    };
    7289    int read(){
    7390        if (bufferlen == 0) {
Note: See TracChangeset for help on using the changeset viewer.