Port scanner in Go

Hello, all.

This is my first message on here and I am just learning go, so please don’t kick hard.

So, I came across this code for a port scanner. I mostly understand what it does, except the semaphore part. When I remove the lock, nothing changes, it works the same. And when I leave the lock in the code and run it, I still get the “too many open files” errors.
Can someone please explain if there is a bug in the code and probably fix it?


You probably created too many concurrent tcp connections (I guess) on a Linux machine. On Linux everything is a file including tcp connections and by default the number of file descriptors is 65535 and perhaps you just run out of this limit. Try to change the number of concurent connections (recomended) or use ulimit command to change the number of system file descriptors.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.