Go Down

Topic: Ethernetsends a String as one char at the time (Read 2217 times) previous topic - next topic


I must do

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

instead of


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++) {

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)


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

are not const methods as they should be.



well... I guess you're gonna have to read through 5100's manual and create a driver yourself. :\
This... is a hobby.


From Ethernet library - Client.cpp

Code: [Select]
void Client::write(uint8_t b) {
 if (_sock != MAX_SOCK_NUM)
   send(_sock, &b, 1);

void Client::write(const char *str) {
 if (_sock != MAX_SOCK_NUM)
   send(_sock, (const uint8_t *)str, strlen(str));

void Client::write(const uint8_t *buf, size_t size) {
 if (_sock != MAX_SOCK_NUM)
   send(_sock, buf, size);

Should be easy ... Try replacing Client.print(str) with Client.write(str), Add a '\n' to the string if using println...

Does this help?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131