i'm using windows XP SP2 + Microsoft Platform SDK February 2003 +
Microsoft Visual C++ 6.0
thanks for answer :)
Ya-Lin Huang
Thanks.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Ya-Lin Huang" <hua...@csie.nctu.edu.tw> wrote in message
news:eSogepoq...@TK2MSFTNGP14.phx.gbl...
7. Open two command line ('cmd'), one for ipv6-enabled-server (server.exe)
and the other for ipv6-enabled-client (client.exe)
Execute server.exe first and then execute client.exe. After that i got
the result where "Using local address ::1, port 1041" showed that
getsockname() correctly retreived IP address the socket used. See below:
A. > server.exe -t TCP -p 5060
'Listening' on port 5060, protocol TCP, protocol family PF_INET6
'Listening' on port 5060, protocol TCP, protocol family PF_INET
Accepted connection from ::1
Received 10 bytes from client: [Message #1]
Echoing same data back to client
Client closed connection
B. > client.exe -t TCP -p 5060
Attempting to connect to: localhost
Connected to ::1, port 5060, protocol TCP, protocol family PF_INET6
Using local address ::1, port 1041
Sent 10 bytes (out of 10 bytes) of data: [Message #1]
Received 10 bytes from server: [Message #1]
Done sending
Server closed connection
8. Open two command line ('cmd'), one for ipv6-enabled-server (server.exe)
and the other for ipv6-enabled-client (client.exe)
Execute server.exe first and then execute client.exe. After that i got
the result where "Using local address ::, port 1042" showed that
getsockname() did NOT correctly retreived IP address the socket used. See
below:
> server.exe -t UDP -p 5060
'Listening' on port 5060, protocol UDP, protocol family PF_INET6
'Listening' on port 5060, protocol UDP, protocol family PF_INET
Received a 10 byte datagram from ::1: [Message #1]
Echoing same data back to client
> client.exe -t UDP -p 5060
Attempting to connect to: localhost
Connected to ::1, port 5060, protocol UDP, protocol family PF_INET6
Using local address ::, port 1042
Sent 10 bytes (out of 10 bytes) of data: [Message #1]
Received 10 bytes from server: [Message #1]
Done sending
I'm wondering what's wrong? Shouldn't getsockname() return an IP address
if my connection is UDP? Or there's something that i misunderstand??
I've tested two machine of Windows XP Professional SP2 and Windows
Server 2003 Standard Edition. Both of them are ipv6 enabled, and the result
are the same...
Thanks for answering... :)
Sincerely,
Ya-Lin Huang
"Raymond Sinnappan [MSFT]" <raym...@online.microsoft.com> 撰寫於郵件新聞:%23cLoczv...@TK2MSFTNGP10.phx.gbl...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/getsockname_2.asp
"A Windows Sockets application must not assume that the address will be
specified unless the socket is connected. The address that will be used for
the socket is unknown unless the socket is connected when used in a
multihomed host. If the socket is using a connectionless protocol, the
address may not be available until I/O occurs on the socket."
Thanks.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Ya-Lin Huang" <hua...@csie.nctu.edu.tw> wrote in message
news:eUWghi8q...@tk2msftngp13.phx.gbl...
But I do another experiment that is pasting the source code segment of
printing out local ip address after send and receive. Using the same code
as i said previous, i added what follows right after
"ReceiveAndPrint(ConnSocket, Buffer, sizeof(Buffer));" in main program in
ipv6-enabled-client.
puts( "--> After send() and recv() something... <--" );
//
// Find out what local address and port the system picked for us.
//
AddrLen = sizeof(Addr);
if (getsockname(ConnSocket, (LPSOCKADDR)&Addr, &AddrLen) ==
SOCKET_ERROR) {
fprintf(stderr, "getsockname() failed with error %d: %s\n",
WSAGetLastError(), DecodeError(WSAGetLastError()));
} else {
if (getnameinfo((LPSOCKADDR)&Addr, AddrLen, AddrName,
sizeof(AddrName), NULL, 0, NI_NUMERICHOST) != 0)
strcpy(AddrName, "<unknown>");
printf("Using local address %s, port %d\n",
AddrName, ntohs(SS_PORT(&Addr)));
}
puts ( "" );
The same procedure as before, I got the same local ip address, "::".
A. > server.exe -t UDP -p 5060
'Listening' on port 5060, protocol UDP, protocol family PF_INET6
'Listening' on port 5060, protocol UDP, protocol family PF_INET
Received a 10 byte datagram from ::1: [Message #1]
Echoing same data back to client
B. > client.exe -t UDP -p 5060
Attempting to connect to: localhost
Connected to ::1, port 5060, protocol UDP, protocol family PF_INET6
Using local address ::, port 1031
Sent 10 bytes (out of 10 bytes) of data: [Message #1]
Received 10 bytes from server: [Message #1]
--> After send() and recv() something... <--
Using local address ::, port 1031
Done sending
With Best Regards,
Ya-Lin Huang
"Raymond Sinnappan [MSFT]" <raym...@online.microsoft.com> 撰寫於郵件新聞:e6$9vK$qEHA...@TK2MSFTNGP10.phx.gbl...
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Ya-Lin Huang" <hua...@csie.nctu.edu.tw> wrote in message
news:ub$it6ArE...@TK2MSFTNGP14.phx.gbl...
Thanks for help :)
Sincerely,
Ya-Lin Huang
"Raymond Sinnappan [MSFT]" <raym...@online.microsoft.com> 撰寫於郵件新聞:e7qJZWNr...@TK2MSFTNGP14.phx.gbl...
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Ya-Lin Huang" <hua...@csie.nctu.edu.tw> wrote in message
news:uh6Q53Nr...@TK2MSFTNGP09.phx.gbl...