Pages: [1]   Go Down
Author Topic: Ethernet sends a String one char at a time  (Read 2241 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I must do

  String str = "Hello World";
  int n = str.length()+1;
  char st[n];
  str.toCharArray(st,n);
  client.print(st);

instead of

  client.print(str)

to send s String in on one TCP/IP packet.

The problem is in Print.cpp:

void Print::print(const String &s)
{
  for (int i = 0; i < s.length(); i++) {
    write(s);
  }
}

and then every write(char)  is send in Client.cpp
as in one TCP/IP packet.  That sinks the transfrer
rate a lot.

It might be idea to do a write(const String &) in Print and
then implement print(const String &) by calling that.

And then in Client one must override write(const String &)
by writing all chars to same packet.

One problem to implement that is that

void String::toCharArray(char *buf, unsigned int bufsize)

and

void String::getBytes(unsigned char *buf, unsigned int bufsize)

are not const methods as they should be.

 smiley-sad
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a hardware problem?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry wrong place.  How do I remove post from this topic group?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How do I remove post from this topic group?
Don't worry about it. Leave it here, but add a link to the new topic in the software forum.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Moved to SW bugs:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1293546575

Thanks.  
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, the correct move address is:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1293545442

 :-X
Logged

Pages: [1]   Go Up
Jump to: