>/dev/null 2>&1
http://www.west263.com/info/html/chengxusheji/Javajishu/20080226/49389.html
http://www.west263.com/info/html/chengxusheji/Javajishu/20080226/49389_2.html
However, when it comes to server-side programming in C/C , there is an additional wrinkle. Namely, depending on whether your application is written for a dual-stack platform, such as Solaris or Linux, or a single-stack platform, such as Windows, you would need to structure the code differently.
Notice that on a dual-stack machine, since one socket, the IPv6 socket, will be able to Access both IPv4 and IPv6 protocol stacks, you only need to create one socket. Thus this server can potentially support both IPv4 and IPv6 clients
Here's the corresponding server C code for a dual-stack platform:
int ServSock, csock;
struct sockaddr addr, from;
...
ServSock = socket(AF_INET6, SOCK_STREAM, PF_INET6);
bind(ServSock, &addr, sizeof(addr));
do {
csock = accept(ServSocket, &from, sizeof(from));
doClientStuff(csock);
} while (!finished);
Here's the C code for the same server for a single-stack platform:
SOCKET ServSock[FD_SETSIZE];
ADDRINFO AI0, AI1;
ServSock[0] = socket(AF_INET6, SOCK_STREAM, PF_INET6);
ServSock[1] = socket(AF_INET, SOCK_STREAM, PF_INET);
...
bind(ServSock[0], AI0->ai_addr, AI0->ai_addrlen);
bind(ServSock[1], AI1->ai_addr, AI1->ai_addrlen);
...
select(2, &SockSet, 0, 0, 0);
if (FD_ISSET(ServSocket[0], &SockSet)) {
// IPv6 connection csock = accept(ServSocket[0], (LPSOCKADDR)&From, FromLen);
...
}
if (FD_ISSET(ServSocket[1], &SockSet))
// IPv4 connection csock = accept(ServSocket[1], (LPSOCKADDR)&From, FromLen);
...
}客户端代码:
大学课件 第07章IPv4和IPv6编程大学课件
http://www.doc88.com/p-98433611979.html
I
P v 4 与 I P v 6 兼 容 网 络 编 程 模 式
http://wenku.baidu.com/view/ef8eae33b90d6c85ec3ac6a7.html
http://cd34.com/blog/infrastructure/conversion-to-dual-stack-ipv6/
http://wenku.baidu.com/view/3b3e0c1514791711cc79172a.html
I
P V 4 与 I P V 6 兼 容 的 s o c k e t 编 程
http://wenku.baidu.com/view/292b9e3283c4bb4cf7ecd182.html
http://download.csdn.net/download/morneve1/2710834