This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Socket: non-blocking connect and getsockopt SO_ERROR


Hi.

I am experiencing an issue with getsockopt when running an application
under CygWin. 

The application (Kannel sms gateway) creates a new socket, attempt to
connect non-blocking to the other host and later calls getsockopt to
check for errors:

s = socket(PF_INET, SOCK_STREAM, 0);
...
flags = fcntl(s, F_GETFL, 0);
fcntl(s, F_SETFL, flags | O_NONBLOCK);
...
connect(s, &addr, sizeof(addr))

connect returns EINPROGRESS and the application has a polling thread
setup to handle timeout and check for changes. In both cases a callback
function is invoked.

The callback function checks the connection by calling 

getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &len)

but it returns 0 and no error - even if the connection was never
established. Subsequently the application tries to write data to the
socket - which fails with a "transport endpoint is not connected" error.

The code works just fine on Linux with getsockopt returning an error.
Any pointer on how to get this working will be greatly appreciated.

BR
  Jacob

--  
Jacob Eiler
Apide ApS
e: jacob.eiler@apide.com
t: +45 2374 0486
w: apide.com



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]