Thread (4 messages) 4 messages, 2 authors, 2009-08-24

Re: Fw: Question about the connect Function and BlueZ.

From: David Sainty <hidden>
Date: 2009-08-22 21:20:16

Abraham J. Velez (EndoraSoft) wrote:
quoted
the problem seems similar or the same to what Nick posted a view weeks
ago. If you use blocking connect() in one thread the close() in another
thread will not terminate the connection attempt. As far as I can tell
this is true and should be fixed. It however works fine if you just
would use proper non-blocking connect() with a mainloop.
The problem of this method is the control of errors. The call to connect
function is blocking (because we need to
know if the user of the terminal can not connect errno==ECONNREFUSED).
Does this not work?  From connect(2):

       EINPROGRESS
              The  socket  is  non-blocking  and the connection cannot 
be com-
              pleted immediately.  It is possible to select(2) or 
poll(2)  for
              completion  by selecting the socket for writing. After 
select(2)
              indicates writability, use getsockopt(2) to  read  the  
SO_ERROR
              option  at  level SOL_SOCKET to determine whether 
connect() com-
              pleted  successfully  (SO_ERROR  is  zero)   or   
unsuccessfully
              (SO_ERROR  is one of the usual error codes listed here, 
explain-
              ing the reason for the failure).
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help