TC/IP Communication

Hello everyone!
I need some help.
I would like to send a message from my computer to my arduino (connected to ethernet shield).
My problem is the following:
When I send someting from my computer I only see '?' character on serial monitor.
C# code:
byte[] outstream = Encoding.ASCII.GetBytes(textBox3.Text);
serverstream.Write(outstream, 0, outstream.Length);
serverstream.Flush();

Arduino code:

for (byte i=0; i < 8; i++) {
if (clients && clients*.available() > 0) {*
* // read bytes from a client*
* byte buffer[80];*
_ int count = clients*.read(buffer, 80);
char character=clients.read();
Serial.print(character);*_

* // write the bytes to all other connected clients*
* for (byte j=0; j < 8; j++) {*
* if (j != i && clients[j].connected()) {*
* clients[j].write(buffer, count);*
* }*
* }*
* }*
* }*
Can I decoding the ASCII code somehow?
Thank you in advance :slight_smile:

if one character is available, you read 80 and then one more. so you read nothing. read() returns -1 if nothing is available (the return type is int for the -1)

to send data to all client you can use server.print functions

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.