From 90025642ce97002910ace4654c64035bb91ad4a8 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Wed, 29 Apr 2020 23:48:37 +0800
Subject: [PATCH] update prj1_tlv source code, test socket client connect ok

---
 ch6_ipc/fifo_chat.c |   37 ++++++++++++-------------------------
 1 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/ch6_ipc/fifo_chat.c b/ch6_ipc/fifo_chat.c
index ec1c3c4..776e605 100644
--- a/ch6_ipc/fifo_chat.c
+++ b/ch6_ipc/fifo_chat.c
@@ -31,8 +31,6 @@
     fd_set         rdset;
     char           buf[1024];
     int            mode = 0;
-    char          *rd_fifo = NULL;
-    char          *wr_fifo = NULL;
 
     if( argc != 2 )
     {
@@ -42,17 +40,6 @@
     }
 
     mode = atoi(argv[1]);
-
-    if( 0 == mode )
-    {
-        rd_fifo = FIFO_FILE1;
-        wr_fifo = FIFO_FILE2;
-    }
-    else
-    {
-        rd_fifo = FIFO_FILE2;
-        wr_fifo = FIFO_FILE1;
-    }
 
     if( access(FIFO_FILE1 , F_OK) )
     {
@@ -70,33 +57,33 @@
 
     if( 0 == mode )
     {
-        printf("start open '%s' for read and it will blocked untill write endpoint opened...\n", rd_fifo);
-        if( (fdr_fifo=open(rd_fifo, O_RDONLY)) < 0 )
+        printf("start open '%s' for read and it will blocked untill write endpoint opened...\n", FIFO_FILE1);
+        if( (fdr_fifo=open(FIFO_FILE1, O_RDONLY)) < 0 )
         {
-            printf("Open fifo[%s] for chat read endpoint failure: %s\n", rd_fifo, strerror(errno));
+            printf("Open fifo[%s] for chat read endpoint failure: %s\n", FIFO_FILE1, strerror(errno));
             return -1;
         } 
         
-        printf("start open '%s' for write...\n", wr_fifo);
-        if( (fdw_fifo=open(wr_fifo, O_WRONLY)) < 0 )
+        printf("start open '%s' for write...\n", FIFO_FILE2);
+        if( (fdw_fifo=open(FIFO_FILE2, O_WRONLY)) < 0 )
         {
-            printf("Open fifo[%s] for chat write endpoint failure: %s\n", wr_fifo, strerror(errno));
+            printf("Open fifo[%s] for chat write endpoint failure: %s\n", FIFO_FILE2, strerror(errno));
             return -1;
         }
     }
     else
     {
-        printf("start open '%s' for write and it will blocked untill read endpoint opened...\n", wr_fifo);
-        if( (fdw_fifo=open(wr_fifo, O_WRONLY)) < 0 )
+        printf("start open '%s' for write and it will blocked untill read endpoint opened...\n", FIFO_FILE1);
+        if( (fdw_fifo=open(FIFO_FILE1, O_WRONLY)) < 0 )
         {
-            printf("Open fifo[%s] for chat write endpoint failure: %s\n", wr_fifo, strerror(errno));
+            printf("Open fifo[%s] for chat write endpoint failure: %s\n", FIFO_FILE1, strerror(errno));
             return -1;
         }
 
-        printf("start open '%s' for read...\n", rd_fifo);
-        if( (fdr_fifo=open(rd_fifo, O_RDONLY)) < 0 )
+        printf("start open '%s' for read...\n", FIFO_FILE2);
+        if( (fdr_fifo=open(FIFO_FILE2, O_RDONLY)) < 0 )
         {
-            printf("Open fifo[%s] for chat read endpoint failure: %s\n", rd_fifo, strerror(errno));
+            printf("Open fifo[%s] for chat read endpoint failure: %s\n", FIFO_FILE2, strerror(errno));
             return -1;
         } 
     }

--
Gitblit v1.9.1