Omron CS1W-ETN21 Network Card User Manual


 
191
FINS/TCP Method Section 7-4
245 int total_len = 0;
246 int recv_len;
247
248 for (;;)
249 {
250 recv_len = recv(sockfd, (char *)buf, len, 0);
251
252 if (recv_len > 0)
253 {
254 if (recv_len < (int)len)
255 {
256 len -= recv_len;
257 buf += recv_len;
258 total_len += recv_len;
259 }
260 else
261 {
262 total_len += recv_len;
263 break;
264 }
265 }
266 else
267 {
268 err_exit("TCP receive error");
269 total_len = 0;
270 break;
271 }
272 }
273
274 return total_len;
275
276 }
277
278 /*
279 *
280 */
281 err_exit(err_msg)
282 char *err_msg;
283 {
284 printf("client: %s %x¥n",err_msg,errno);
285 exit(1);
286 }
287
288 /*
289 *
290 */
291 recv_fail()
292 {
293 printf("response timeout error ¥n");
294 }
ERROR PROCESSING FUNCTIONS
SIGNAL CAPTURE FUNCTIONS