Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - UDP sockets can not be disconnected on QNX. AF_UNSPEC not supported.: (6 Items)
   
UDP sockets can not be disconnected on QNX. AF_UNSPEC not supported.  

The attached program when compiled and linked for qnx6.5  


$ ./tmp/UDP  10.131.1.141 
before connect 
Local binding: address=10.131.1.141, port=65426
before disconnect 
connect failed: Address family not supported by protocol family
Local binding: address=0.0.0.0, port=65426
before disconnect -2222222222222222
Local binding: address=10.131.1.141, port=65426
bind again 
Local binding: address=10.131.1.141, port=65426

while this runs fine on Linux. 


Can you please let me know if its possible to disconnect from a UDP socket on qnx6.5 ?

Attachment: Text UDPSocket_linux.c 2.26 KB
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: RE: UDP sockets can not be disconnected on QNX. AF_UNSPEC not supported.  
Gravis, 

Your help is appreciated.. It works in actuality.. Do you know why this error is reported in this case? i dont assume 
that this is how it was designed to work. is it? 
Re: RE: UDP sockets can not be disconnected on QNX. AF_UNSPEC not supported.  
i meant Gervais.. I am sorry for the typo on the name.. sincere apologies.

RE: RE: UDP sockets can not be disconnected on QNX. AF_UNSPEC not supported.  
Hello Stefan,

I am not sure why the error is reported, but based on the output of your test program it looked like it changed 
something hence why I figured let's check to see if the connection was "disconnected".

I would imagine that different OSes behave differently, some might report an error others might not.

Gervais
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 ?