From e031d191e75c71fa162f9f898023116cfcbd8a04 Mon Sep 17 00:00:00 2001 From: Guo Wenxue <guowenxue@gmail.com> Date: Fri, 16 Nov 2018 13:36:34 +0800 Subject: [PATCH] Update thread socket server program, add lowercase to uppercase convert --- ch4_thread/socket_server_thread.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/ch4_thread/socket_server_thread.c b/ch4_thread/socket_server_thread.c index 5446eb0..f2150a7 100644 --- a/ch4_thread/socket_server_thread.c +++ b/ch4_thread/socket_server_thread.c @@ -8,6 +8,7 @@ #include <stdlib.h> #include <getopt.h> #include <pthread.h> +#include <ctype.h> typedef void *(THREAD_BODY) (void *thread_arg); @@ -158,6 +159,7 @@ int clifd; int rv; char buf[1024]; + int i; if( !ctx ) { @@ -189,6 +191,12 @@ { printf("Read %d bytes data from Server: %s\n", rv, buf); } + + /* convert letter from lowercase to uppercase */ + for(i=0; i<rv; i++) + { + buf[i]=toupper(buf[i]); + } rv=write(clifd, buf, rv); if(rv < 0) -- Gitblit v1.9.1