⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tclose.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/socktest/tclose.c,v 1.1.1.1 2001/11/05 17:49:14 tneale Exp $ *//* * Copyright (C) 1999-2005 Wind River Systems, Inc. * All rights reserved.  Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//**************************************************************************** *  Copyright 1999 Integrated Systems, Inc. *  All rights reserved. ****************************************************************************//* * $Log: tclose.c,v $ * Revision 1.1.1.1  2001/11/05 17:49:14  tneale * Tornado shuffle * * Revision 1.2  2001/01/19 22:24:53  paul * Update copyright. * * Revision 1.1  2000/10/16 19:22:26  paul * Renamed from test_close.c * * Revision 1.3  2000/03/17 00:14:46  meister * Update copyright message * * Revision 1.2  1999/07/30 21:29:41  paul * enhanced test_fail, test_pass * * Revision 1.1  1999/05/03 19:21:51  paul * Initial revision. * *//* [clearcase]modification history-------------------01a,19apr05,job  update copyright notices*/#include "test.h"#define TEST_PORT 45567static voidtest_c(char *name, struct linger *li, int delay){  int s;  struct sockaddr_in si;  unsigned char buf = (unsigned char) delay;  time_t start, end;  char str[64];  if ((s = socket(PF_INET, SOCK_STREAM, 0)) < 0) {    test_fail(0, name, "socket");    return;  }  memset(&si, 0, sizeof(si));  si.sin_family = AF_INET;  si.sin_addr.s_addr = server;  si.sin_port = htons(TEST_PORT);  if (setsockopt(s, SOL_SOCKET, SO_LINGER, (const void *) li, sizeof(*li)) != 0)    test_fail(0, name, "setsockopt(SO_LINGER)");  if (connect(s, (struct sockaddr *) &si, sizeof(si)) != 0)    test_fail(0, name, "connect");  else if (send(s, (const void *) &buf, sizeof(buf), 0) != sizeof(buf))    test_fail(0, name, "send");  time(&start);  close(s);  time(&end);  sprintf(str, "%d sec", (int)(end - start));  test_pass(0, name, str);}voidtest_close(int flags){  struct linger li;  if ((flags & TEST_TCP) == 0)    /* udp and raw close don't do anything worth testing for */    return;  memset(&li, 0, sizeof(li));  test_c("non-blocking graceful close", &li, 1);  li.l_onoff = 1;  test_c("abort close", &li, 1);  li.l_linger = 10;  test_c("blocking graceful close", &li, 0);  test_c("delayed close, less than linger time", &li, 3);  test_c("delayed close, more than linger time", &li, 11);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -