Get socket buffer to array UIP ENC28j60

Hello,
How I can copy the buffer of socket message to an byte array? This is the TCPClient example:
if (EthernetClient client = server.available()){
if (client){
while((size = client.available()) > 0){
uint8_t* msg = (uint8_t*)malloc(size);
size = client.read(msg,size);
Serial1.write(msg,size);
client.write(msg,size);
for(i=0;i<size;i++){
Serial1.print(*(msg + i));
}
free(msg);
}
}

When I sen 0xFF via socket on the line Serial1.write(msg,size); returns FF its good…
But for cycle Serial1.print(*(msg + i)); return 3 bytes like 2 5 5 means 3 bytes… instead 1 byte FF
I’m using this library GitHub - ntruchsess/arduino_uip: UIPEthernet: A plugin-replacement of the stock Arduino Ethernet library for ENC28J60 shields and breakout boards. Full support for persistent (streaming) TCP-connections and UDP (Client and Server each), ARP, ICMP, DHCP and DNS. Build around Adam Dunkels uIP Stack. Further developed version can be found on https://github.com/UIPEthernet/UIPEthernet

But for cycle Serial1.print(*(msg + i)); return 3 bytes like 2 5 5 means 3 bytes... instead 1 byte FF

The value 0xFF is the same as the value 255. In one case, you are printing the binary value in HEX. In the other case, you are printing the decimal value as a string.

The code is doing exactly what it should. What is the problem?

Hello, thanks, I want to obtain the byte hex to save on byte array to procces it and not as string like second code.

Hello I solve my problem:

if (client.available() > 0) {
// read the bytes incoming from the client:
char thisChar = client.read();
// echo the bytes back to all other connected clients:
for (byte i=0;i<4;i++) {
if (clients && clients*!=client) {*
_ clients*.write(thisChar);
}
}
// echo the bytes to the server as well:
Serial.write(thisChar);
}*
As said PaulS i need to get as chars, thanks… :slight_smile:_