Changeset 668 for trunk/user
- Timestamp:
- Oct 10, 2020, 6:38:47 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user/tcp_server/tcp_server.c
r660 r668 129 129 exit( 0 ); 130 130 } 131 else 132 { 133 printf("\n[server] listening socket[%x,%d] bound : [%x,%x]\n", 134 pid, listen_fdid, server_sin.sin_addr, server_sin.sin_port ); 135 } 131 132 printf("\n[server] listening socket[%x,%d] bound : [%x,%x]\n", 133 pid, listen_fdid, server_sin.sin_addr, server_sin.sin_port ); 136 134 137 135 // 3. Listen clients connection requests … … 144 142 exit( 0 ); 145 143 } 146 else147 {148 printf("\n[server] listening socket[%x,%d] waiting connection request\n",149 pid, listen_fdid );150 }151 144 145 printf("\n[server] listening socket[%x,%d] waiting connection request\n", 146 pid, listen_fdid ); 152 147 153 148 // 4. accept connection(s) … … 156 151 &addr_length ); 157 152 158 if( chat_fdid == -1)153 if( chat_fdid < 0 ) 159 154 { 160 155 printf("\n[server error] accept failure on socket[%x,%d]\n", … … 162 157 exit( 0 ); 163 158 } 164 else 165 { 166 printf("\n[server] chat socket[%x,%d] accepted client [%x,%x]\n", 167 pid, chat_fdid , client_sin.sin_addr , client_sin.sin_port ); 168 } 159 160 printf("\n[server] chat socket[%x,%d] accepted client [%x,%x]\n", 161 pid, chat_fdid , client_sin.sin_addr , client_sin.sin_port ); 169 162 170 163 // 5. call chat function 171 //server_chat( chat_fdid );164 server_chat( chat_fdid ); 172 165 173 166 // 6. close listen and chat sockets 174 175 printf("\n[server] before close socket[%x,%d]\n", pid, chat_fdid );176 177 167 close( chat_fdid ); 178 179 printf("\n[server] after close socket[%x,%d]\n", pid, chat_fdid );180 181 168 close( listen_fdid ); 182 169
Note: See TracChangeset
for help on using the changeset viewer.