0

I am sending the server a message. For example: "Hello World." I want the server to send back the message: "hello world."

for(;;) //listen forever
{
    ClntLen = sizeof(ClntAddr);
    NewSockfd = Accept(Sockfd, (sockaddr*)&ClntAddr, &ClntLen);

    //Read message
    read(NewSockfd, Buff, MAX_SIZE);
    //convert to lower, send back to client
    write(NewSockfd, Buff, MAX_SIZE);
    close(NewSockfd);
}

I have tried using tolower(), but in a server I just can't get it right without giving me errors.

Summary: Read Buff (char array), convert it to lowercase, Write it back to the client.

Please explain how its done. Thanks in advance.

user2369405
  • 217
  • 1
  • 4
  • 10

1 Answers1

0

Show us your code to call tolower, please

When you call read, you should get its return value as the actual data returned from socket and then call tolower to convert them to lowercase and then send this buffer back with the length it returned from read.

Renjie
  • 41
  • 2