|
RE: UDP sockets can not be disconnected on QNX. AF_UNSPEC not supported.
|
11/02/2015 10:17 AM
post114864
|
RE: UDP sockets can not be disconnected on QNX. AF_UNSPEC not supported.
If you ignore the error message have you validated that the socket was "disconnected"?
|
|
|
|
Re: UDP sockets can not be disconnected on QNX. AF_UNSPEC not supported.
|
03/21/2018 5:47 AM
post118687
|
Re: UDP sockets can not be disconnected on QNX. AF_UNSPEC not supported.
I've struggled with the same issue on QNX v7.0 armle
My program creates DGRAM socket and connects to specific address/port. During connection DGRAM socket automatically
bounds to the local address. After that I have to disconnect DGRAM socket and continue send/receive packets without
connection to remote host.
According to documentation of connect function (http://www.qnx.com/developers/docs/7.0.0/index.html#com.qnx.doc.neutrino
.lib_ref/topic/c/connect.html): "Datagram sockets may dissolve the association by connecting to an invalid address, such
as a null address". Unfortunately It seems does not work:
1) connect(fd, NULL, 0)
returns EFAULT and UDP connection remains connected to remote host/port
2) memset(&addr, 0, addr_len);
connect(fd, (struct sockaddr *)&addr, addr_len)
returns EAFNOSUPPORT but DGRAM connection successfully disconnected from the remote host. However this operation
breaks binding of DGRAM socket to local address:
getsockname(fd, (struct sockaddr *)&addr, &addr_len) always returns 0.0.0.0 address. Any subsequent calls to bind(fd
, struct sockaddr *)&local_addr, addr_len) fails with EINVAL. So, no way to fix binding to the correct local host
address.
What is the correct way to disconnect UDP socket without side effects ?
|
|
|