Quantcast
Channel: Forum - Recent Threads
Viewing all articles
Browse latest Browse all 5781

ECONNREFUSED with a non-blocking connect on SSP 1.3.0

$
0
0

Hello,

 

I have the following issue with SSP 1.3.0 on S7G2DK board.

I implemented a non blocking socket connect in the following manner:

- set the non-blocking mode (O_NONBLOCK) for the socket by using fcntl()

- call connect(), which immediately returns with EINPROGRESS, as expected

- restore the socket flags using fcntl()

- then, the socket connection is checked periodically, once every 250ms, like this:

  - select the socket to check if it has any available file descriptors for write

  - if it has 0 file descriptors, just re-check after another 250ms

  - if it has at least 1 file descriptor, get the socket error with the function getsockopt(), SO_ERROR

  - if there is no socket error, then the connect() was ok, otherwise it was ko

 

This implementation works most of the time, I connect in an infinite loop to www.example.com, but after a certain number of successful connects, I get this behavior:

- the select() takes ~ 40 calls until it returns a value > 0 (40 calls * 250ms between call). Usually, the select() returns after 1-2 calls

- after this long select(), the getsockopt() returns ECONNREFUSED. Tried at this point to retrieve the socket peer information with getpeername() but it returns no valid IP and port, so clearly the socket is not connected

 

After this faulty behavior is encountered, the connects doesn't "recover" and they continuously output this behavior.

 

Could you please provide some support to understand this issue?

 

Thanks,

Valentin


Viewing all articles
Browse latest Browse all 5781

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>