Re: Checking if a port is listening

2016-03-26 Thread Lucien via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 20:44:12 UTC, Lucien wrote: Hello, I want to know if a port of an ip address is listening, actually, I've this : http://pastebin.com/pZhm0ujy (checking port 22/ssh) It works, but it took me ~10min to scan 30 addresses. How can reduce the expiration delay ?

Re: Checking if a port is listening

2016-03-24 Thread Lucien via Digitalmars-d-learn
On Thursday, 24 March 2016 at 12:17:35 UTC, Marc Schütz wrote: On Wednesday, 23 March 2016 at 21:37:09 UTC, Lucien wrote: When I remove the Thread.sleep, it doesn't find all adresses. Why ? Socket.select() will wait _at most_ 100 msecs. If a socket gets ready before that timeout, it will

Re: Checking if a port is listening

2016-03-24 Thread Marc Schütz via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 21:37:09 UTC, Lucien wrote: When I remove the Thread.sleep, it doesn't find all adresses. Why ? Socket.select() will wait _at most_ 100 msecs. If a socket gets ready before that timeout, it will return immediately. Therefore, you might not get the full

Re: Checking if a port is listening

2016-03-23 Thread Lucien via Digitalmars-d-learn
On Saturday, 19 March 2016 at 18:24:38 UTC, Marc Schütz wrote: On Saturday, 19 March 2016 at 09:55:13 UTC, Lucien wrote: const int MAX = 64; Socket[] sockets = new Socket[MAX]; string ipb = "192.168.0."; for (int i = 1; i < MAX; i++) { Here's the reason for your SEGV: You

Re: Checking if a port is listening

2016-03-20 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 17 March 2016 at 10:41:55 UTC, Marc Schütz wrote: On Wednesday, 16 March 2016 at 22:22:15 UTC, Anonymouse wrote: import core.thread; // for .seconds Nitpick: `seconds` is defined in `core.time`; `core.thread` just reexports it. s.setOption(SocketOptionLevel.SOCKET, SNDTIMEO,

Re: Checking if a port is listening

2016-03-19 Thread Lucien via Digitalmars-d-learn
On Saturday, 19 March 2016 at 18:24:38 UTC, Marc Schütz wrote: On Saturday, 19 March 2016 at 09:55:13 UTC, Lucien wrote: const int MAX = 64; Socket[] sockets = new Socket[MAX]; string ipb = "192.168.0."; for (int i = 1; i < MAX; i++) { Here's the reason for your SEGV: You

Re: Checking if a port is listening

2016-03-19 Thread Marc Schütz via Digitalmars-d-learn
On Saturday, 19 March 2016 at 09:55:13 UTC, Lucien wrote: const int MAX = 64; Socket[] sockets = new Socket[MAX]; string ipb = "192.168.0."; for (int i = 1; i < MAX; i++) { Here's the reason for your SEGV: You need to start at 0, because otherwise `sockets[0]` is `null`. When

Checking if a port is listening

2016-03-19 Thread Lucien via Digitalmars-d-learn
Hello, I want to know if a port of an ip address is listening, actually, I've this : http://pastebin.com/pZhm0ujy (checking port 22/ssh) It works, but it took me ~10min to scan 30 addresses. How can reduce the expiration delay ?

Re: Checking if a port is listening

2016-03-19 Thread Lucien via Digitalmars-d-learn
On Friday, 18 March 2016 at 09:50:12 UTC, Marc Schütz wrote: Looking at an strace of nmap, it seems it opens a bunch of sockets, puts them into non-blocking mode, calls connect on them (which will return EINPROGRESS), and then uses select(2) to wait for them (in a loop, until all have either

Re: Checking if a port is listening

2016-03-19 Thread Marc Schütz via Digitalmars-d-learn
Looking at an strace of nmap, it seems it opens a bunch of sockets, puts them into non-blocking mode, calls connect on them (which will return EINPROGRESS), and then uses select(2) to wait for them (in a loop, until all have either been accepted or rejected). select(2) accepts a timeout value,

Re: Checking if a port is listening

2016-03-19 Thread Marc Schütz via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 22:22:15 UTC, Anonymouse wrote: import core.thread; // for .seconds Nitpick: `seconds` is defined in `core.time`; `core.thread` just reexports it. s.setOption(SocketOptionLevel.SOCKET, SNDTIMEO, 10.seconds); s.setOption(SocketOptionLevel.SOCKET, RCVTIMEO,

Re: Checking if a port is listening

2016-03-19 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 20:44:12 UTC, Lucien wrote: Hello, I want to know if a port of an ip address is listening, actually, I've this : http://pastebin.com/pZhm0ujy (checking port 22/ssh) It works, but it took me ~10min to scan 30 addresses. How can reduce the expiration delay ? I

Re: Checking if a port is listening

2016-03-19 Thread Lucien via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 22:22:15 UTC, Anonymouse wrote: On Wednesday, 16 March 2016 at 20:44:12 UTC, Lucien wrote: Hello, I want to know if a port of an ip address is listening, actually, I've this : http://pastebin.com/pZhm0ujy (checking port 22/ssh) It works, but it took me ~10min

Re: Checking if a port is listening

2016-03-19 Thread Timothee Cour via Digitalmars-d-learn
see also: https://github.com/rejectedsoftware/vibe.d/issues/1431 api to find an available port On Fri, Mar 18, 2016 at 2:50 AM, Marc Schütz via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Looking at an strace of nmap, it seems it opens a bunch of sockets, puts > them