comparison packages/net/tcpip/current/tests/server_test.c @ 115:6ed91473a1cd ecos-sw-2000-08-21

Merge from eCos master repository on 2000-08-21-22:40:54-BST
author jlarmour
date Fri, 25 Aug 2000 17:32:38 +0000
parents 84e4bde58b26
children 0d2b193a635f
comparison
equal deleted inserted replaced
114:5ad2b71d525e 115:6ed91473a1cd
51 //####DESCRIPTIONEND#### 51 //####DESCRIPTIONEND####
52 // 52 //
53 //========================================================================== 53 //==========================================================================
54 // Network server test code 54 // Network server test code
55 #include <stdio.h> 55 #include <stdio.h>
56 #include <stdlib.h>
56 #include <network.h> 57 #include <network.h>
58
59 #ifndef CYGPKG_LIBC_STDIO
60 #define perror(s) diag_printf(#s ": %s\n", strerror(errno))
61 #endif
57 62
58 #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000) 63 #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000)
59 static char stack[STACK_SIZE]; 64 static char stack[STACK_SIZE];
60 static cyg_thread thread_data; 65 static cyg_thread thread_data;
61 static cyg_handle_t thread_handle; 66 static cyg_handle_t thread_handle;
106 pexit("accept"); 111 pexit("accept");
107 } 112 }
108 client_len = sizeof(client_addr); 113 client_len = sizeof(client_addr);
109 getpeername(client, (struct sockaddr *)&client_addr, &client_len); 114 getpeername(client, (struct sockaddr *)&client_addr, &client_len);
110 diag_printf("connection from %s:%d\n", inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port)); 115 diag_printf("connection from %s:%d\n", inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port));
116
117 #ifdef CYGPKG_LIBC_STDIO
111 sprintf(buf, "Hello %s:%d\n", inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port)); 118 sprintf(buf, "Hello %s:%d\n", inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port));
119 #else
120 strcpy(buf, "Hello ");
121 strcat(buf, inet_ntoa(client_addr.sin_addr));
122 strcat(buf,":");
123 strcat(buf, atoi(ntohs(client_addr.sin_port)));
124 strcat(buf,"\n");
125 #endif
126
112 write(client, buf, strlen(buf)); 127 write(client, buf, strlen(buf));
113 tv.tv_sec = 5; 128 tv.tv_sec = 5;
114 tv.tv_usec = 0; 129 tv.tv_usec = 0;
115 FD_ZERO(&in_fds); 130 FD_ZERO(&in_fds);
116 FD_SET(client, &in_fds); 131 FD_SET(client, &in_fds);