Pages: [1]   Go Down
Author Topic: Ethernet library reference change #2  (Read 1213 times)
0 Members and 1 Guest are viewing this topic.
Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 148
Posts: 6104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As long as you are in the ethernet library reference, the following pages need an addition.
http://arduino.cc/en/Reference/ClientWrite
http://arduino.cc/en/Reference/ServerWrite

The pages are missing one of the most useful functions if you plan on sending any NULL (zero) bytes.
client.write(dataString,count);
server.write(dataString,count);

Parameters
dataString: the array to write (byte or char array pointer)
count: the number of bytes of the dataString array to write (int)

edit: Corrected dataString parameter to "byte or char array pointer".
« Last Edit: July 06, 2013, 07:41:07 am by SurferTim » Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 148
Posts: 6104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Bump. Did you have a nice nap?

edit: Here is the library code (declarations) from EthernetClient.h
Code:
 virtual size_t write(uint8_t);
  virtual size_t write(const uint8_t *buf, size_t size);

Here is the code from EthernetClient.cpp
Code:
size_t EthernetClient::write(uint8_t b) {
  return write(&b, 1);
}

size_t EthernetClient::write(const uint8_t *buf, size_t size) {
  if (_sock == MAX_SOCK_NUM) {
    setWriteError();
    return 0;
  }
  if (!send(_sock, buf, size)) {
    setWriteError();
    return 0;
  }
  return size;
}
« Last Edit: July 10, 2013, 06:46:08 am by SurferTim » Logged

Global Moderator
Milano, Italy
Offline Offline
Edison Member
*****
Karma: 23
Posts: 1180
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi SurferTim,

I've edited the Client and Server write() pages, thanks for the suggestion and for noticing.
I preferred to keep the explanation close to the one given to Serial write() documentation.
Hope you like it.
Logged

F

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 148
Posts: 6104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That looks good to me!  smiley

One down, two to go!
Logged

Global Moderator
Milano, Italy
Offline Offline
Edison Member
*****
Karma: 23
Posts: 1180
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

One.  smiley
DNS fixed. Only the UDP.stop() to go
Logged

F

Pages: [1]   Go Up
Jump to: