问题
I would like to make a cocoa app that will check if some TCP ports are opened on a server. Return a little red ball if it's closed, or green if it's open...
But I'm little bit confused, what class to use, etc.
Thanks in advance for your help
回答1:
If it is enough just to connect to the the port and close it, the simplest thing is to use the BSD calls:
- create a socket using socket()
- connect to the remote port using connect()
- close the socket using close()
来源:https://stackoverflow.com/questions/7997126/how-to-check-a-tcp-port-with-cocoa-osx-sdk