Changeset 114 for branches/follower/wiz810mj/src/demo
- Timestamp:
- 12/11/07 04:18:09 (13 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/follower/wiz810mj/src/demo/WizDemo4/WizDemo4.pde
r113 r114 227 227 int listen(); 228 228 int isConnected(); 229 int available(); 229 230 int read(); 230 231 void NetworkConnection::close(); … … 250 251 } 251 252 253 int NetworkConnection::available() { 254 /* 255 256 Functionality matches 'Serial.available()'. 257 258 Note: If the socket is not connected then this will return 0, 259 but it is intended that 'isConnected()' would be checked first. 260 261 Returns: 262 "The number of bytes available to read ... or 0 if none are available. 263 If any data has come in, [...].available() will be greater than 0." 264 265 */ 266 // TODO: Do we want to check for 'isConnected' as well, or not? 267 // We have to, I guess, for valid behaviour with 'getSn_*'. 268 if (!isConnected()) { 269 return 0; 270 } 271 272 return getSn_RX_RSR(_socket); 273 } 274 275 #define NO_READ_DATA_AVAILABLE -1 276 252 277 int NetworkConnection::read() { 253 278 /* 279 280 Functionality matches 'Serial.read()'. 281 282 Returns: 283 "an int, the first byte of incoming serial data available 284 (or -1 if no data is available)." 285 254 286 255 287 Note: I thought 'recv' blocked until data was available, … … 262 294 */ 263 295 uint8_t theByte; 296 297 if (!available()) { 298 return NO_READ_DATA_AVAILABLE; 299 } 300 264 301 recv(_socket, &theByte, 1); 265 302 return theByte; … … 403 440 404 441 Serial.println("Connected..."); 442 443 while (conn.isConnected()) { 444 if (conn.available()) { 445 Serial.print(conn.read(), BYTE); 446 } 447 } 448 449 Serial.println(""); 405 450 406 451 conn.close();