Select in non-blocking sockets

Select in non-blocking sockets

Post by OscarG » Wed, 15 Jan 2003 20:59:05



I've finally get a non-blocking socket, but I can't know whether
the connect has been accepted (I mean, if the port is opened in
destiny server).

I make a connect which return a -1 (Ok, he don't know jet the result)
After that i make a select (with a 5sec timeout). the time spires and
the select return a 0.
But although the select return a 0 the socket is writable.

I want to do portscanner with a conect timeout but I can't If the select
don't detect the accept or refuse of my connect

There's something I can do?

thanks scar

--
Posted via http://dbforums.com

 
 
 

Select in non-blocking sockets

Post by Barry Margoli » Thu, 16 Jan 2003 00:19:43




>I've finally get a non-blocking socket, but I can't know whether
>the connect has been accepted (I mean, if the port is opened in
>destiny server).

>I make a connect which return a -1 (Ok, he don't know jet the result)

Did you actually check errno to make sure it's EINPROGRESS?  Any other code
is a real error.

Quote:>After that i make a select (with a 5sec timeout). the time spires and
>the select return a 0.
>But although the select return a 0 the socket is writable.

Maybe there's a problem with the way you're calling connect().  Post your
code.

Quote:>I want to do portscanner with a conect timeout but I can't If the select
>don't detect the accept or refuse of my connect

There are already plenty of good port scanners, why don't you just use one
of them (like nmap)?

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

1. select() behavior for Blocking and non-blocking sockets.

Hi,

This is a question on select() usage:

I've a scenerio wherein I expect connect() requests
from multiple clients. My server application starts
up different instances to service the client requests.
I'm using select() call with readfd set to the bind'ed
socket to accept the connections.
I notice a peculiar thing:
If the client sends a connect() to the server, the
connect() call succeeds, but, the server doesn't come
to know of the client connect request.

However, if I change the listening socket on the server
to NON-Blocking, (using ioctl with FIONBIO), the server
does accept connection.

I would like to know the concept behind this. Why doesn't
the server get the connect request incase of blocking socket ?

I sincerely appreciate your comments/suggestions.

Regards,
Vishal Murgai.

------------------------------------------------------------------------

2. connecting linux to the internet

3. select and non-blocking sockets

4. Help installing FreeBSD on an Alpha multia

5. select & non-blocking socket

6. UFSDUMP-REWIND

7. Using select() on non-blocking socket?

8. Upgrade RedHat Kernel

9. Problem with select() and non-blocking sockets

10. select() returns and indicates writability before a non-blocking TCP socket has actually connected.

11. Blocking and Non-Blocking socket

12. Non-blocking socket reads block! (Bug?)

13. Difference between blocking and non-blocking socket ?