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

📄 tgetsock.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/socktest/tgetsock.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 1998 Integrated Systems, Inc. *  All rights reserved. ****************************************************************************//* * $Log: tgetsock.c,v $ * Revision 1.1.1.1  2001/11/05 17:49:14  tneale * Tornado shuffle * * Revision 1.2  2001/01/19 22:24:54  paul * Update copyright. * * Revision 1.1  2000/10/16 19:22:37  paul * Renamed from test_getsockname.c * * Revision 1.8  2000/03/17 00:14:47  meister * Update copyright message * * Revision 1.7  1999/07/30 21:29:42  paul * enhanced test_fail, test_pass * * Revision 1.6  1999/05/21 19:34:00  niqbal * PNA isn;t exactly like BSD, atleast in returning the error * numbers. So removing the TEST_PNA flag from code that should be tested * on BSD only. * * Revision 1.4  1999/02/18 04:16:03  wes * Socket Merge: new code (socket tests). * * Revision 1.3.2.4  1998/11/06 23:36:50  paul * rototill to support tcp * *//* [clearcase]modification history-------------------01a,19apr05,job  update copyright notices*/#include "test.h"static voidtest_gs(char *name, int s, struct sockaddr_in *si, int *si_len,	int expected, int expected_errno){  if (test(0, name, 	   getsockname(s, (struct sockaddr *) si, si_len), 	   expected, expected_errno) == 0)    pr_sockaddr_in(si);}voidtest_getsockname(int flags){  int s;  struct sockaddr_in si;  int si_len = sizeof(struct sockaddr_in);  memset(&si, 0, sizeof(si));  s = socket(PF_INET, SOCK_DGRAM, 0);  if (s < 0) {    test_fail(0, "getsockname", "socket");    return;  }  test_gs("getsockname invalid descriptor", 	  -1, &si, &si_len,	  -1, EBADF);#ifdef TEST_BSD  test_gs("getsockname file descriptor", 	  1, &si, &si_len,	  -1, ENOTSOCK);#endif  test_gs("getsockname unbound socket", 	  s, &si, &si_len,	  0, 0);  si.sin_port = htons(1234);  si.sin_addr.s_addr = htonl(INADDR_ANY);  bind(s, (struct sockaddr *) &si, sizeof(si));  si_len = 4;  test_gs("getsockname invalid namelen", 	  s, &si, &si_len,	  0, 0);  test_gs("getsockname null namelen", 	  s, &si, 0,	  -1, EFAULT);  test_gs("getsockname null name", 	  s, 0, &si_len,	  -1, EFAULT);  if (shutdown(s, 2) != 0) {    test_fail(0, "getsockname", "shutdown");  }  else {    si_len = sizeof(struct sockaddr_in);    test_gs("getsockname shutdown socket",	    s, &si, &si_len,	    0, 0);  }  close(s);}

⌨️ 快捷键说明

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