I am including a code sample that I plan to add to the draft. Please review the
code below and comment.
There is another topic that we need to finalize regarding the blocking vs
non-blocking nature of the setsockopt() function but I prefer to discuss it
under a separate email to simplify the tracking of the info. Clearly, if we
decide to make changes to the function (or add a new function), the code sample
will be updates.
Danny
------------ Code Sample ---------------
#include <sys/socket.h>
#include <netinnet/in.h>
int s ;
// Socket id
sockaddr_in6 serverAddress ;
// server info for connect()
uint32_t flags = IPV6_REQUIRE_SESSION_LASTING_IP ;
// For requesting a Session-Lasting source IP address
// Create an IPv6 TCP socket
s = socket(AF_INET6, SOCK_STREAM, 0) ;
if (s!=0) {
// Handle socket creation error
// ...
} // if socket creation failed
else {
// Socket creation is successful
// The application cannot connect yet, since it wants to use a
Session-Lasting source IP address
// It needs to request the Session-Lasting source IP before
connecting
if (setsockopt(s, IPPROTO_IPV6, IPV6_ADDR_PREFERENCE, (void *)
flags, sizeof(flags)) == 0){
// setting session continuity to Session Lasting is successful
// The application can connect to the server
// Set the desired server's port# and IP address
serverAddress.sin6_port = serverPort ;
serverAddress.sin6_addr = serverIpAddress ;
// Connect to the server
if (connect(s, &serverAddress,
sizeof(serverAddress)) == 0) {
// connect successful (3-way
handshake has been completed with Session-Lasting source address
// Continue application
functionality
// ...
} // if connect() is successful
else {
// connect failed
// ...
// Application code that handles
connect failure and closes the socket
// ...
} // if connect() failed
} // if the request of a Session-Lasting source address was
successful
else {
// application code that does not use
Session-lasting IP address
// The application may either connect without
the desired Session-lasting service, or close the socket
//...
} // if the socket was successfully created but a
Session-Lasting source address was not provided
} // if socket was created successfully
// The rest of the application's code
// ...
----------------- Code Sample -----------------
---------------------------------------------------------------------
A member of the Intel Corporation group of companies
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
_______________________________________________
dmm mailing list
[email protected]
https://www.ietf.org/mailman/listinfo/dmm