[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(usagi-users 02370) Re: IPv6 replcement for sendto() ?



I'd like to use the first option - how do I perform this cast? I can't just use:
sendto(sock, &packet6, sizeof(packet6), 0, (struct sockaddr_storage *)&sin6, sizeof(sin6));

as I'm getting a compilation error., of course.

Strangely, I'm getting as the result of sendto() 0, with errno

[I do not wish (for the time being) to conceal IP version.]



Mitsuru KANDA / 神田 充 wrote:
You can just use 'to' by casting sockaddr_storage structure.
(sockaddr_in{} is small for IPv6 address.)



getaddrinfo()-send*() combination is more useful.
(It can conceal IP version.)

struct addrinfo hints, *res, *res0;
getaddrinfo(host, service, &hints, &res0);
...
for (res=res0; res; res = res->ai_next) {
	s = socket(res->ai_family, res->ai_socktype,
					res->ai_protocol);
	...

	sendto(s, buf, n, 0, res->ai_addr, res->ai_addrlen);
	....
}
	



At Tue, 13 May 2003 16:20:32 +0200,
Yaniv Kaul <ykaul@xxxxxxxxxxxxxx> wrote:
  
I'm trying to port an application to IPv6.
What is the IPv6 'sendto' function?
I'm especially stuck with the 5th parameter of the sendto() function - *to :

int  sendto(int s, const void *msg, size_t len, int flags, const struct
       sockaddr *to, socklen_t tolen);

Could it be sendmsg() ? I was hoping for sendto6() or something ;-)