本文介绍了如何检查TCP端口与Cocoa OSX SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想制作一个可可应用程序,它将检查是否有一些TCP端口在服务器上打开。
如果它关闭,返回一个红色的球,或者如果它打开则返回绿色...
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.
先感谢您的帮助
推荐答案
只需连接到端口并关闭它,最简单的事情是使用BSD调用:
If it is enough just to connect to the the port and close it, the simplest thing is to use the BSD calls:
- 使用 socket()
- 使用
- 使用
- create a socket using socket()
- connect to the remote port using connect()
- close the socket using close()
这篇关于如何检查TCP端口与Cocoa OSX SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!