本文介绍了如何在Objective-C中侦听网络端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为可以在特定网络端口上侦听流量的iPhone制作应用程序。

I am trying to make an application for iPhone that can listen for traffick on a specific network port.

我网络上的服务器正在发送消息(不同状态在特定端口上的服务器处理的设备的消息。

A server on my network is sending out messages (different status messages for devices the server handles) on a specific port.

我的问题是,当我创建一个线程和makePairWithSocket时,我阻止了其他想要发送消息的人的端口服务器,所以我只想听取指定端口上的流量,然后检查特定的heraders,然后使用这些消息。
我知道如何使用写入和读取流建立连接并与服务器通信,但后来我使用makePairWithSocket并阻止网络上所有其他设备的端口

My problem is that when I make a thread and makePairWithSocket I block the port for others who want to send messages to the server, so I only want to listen to the traffic on a specifyed port and then check for specific heraders and then use those messages.I know how to make the connection and talk to the server using write and read streams, but then I makePairWithSocket and block the port for all other devices on the network

对于如何在没有与服务器配对的情况下监听Objective-C中的端口有任何建议?

Any one that has any suggestions on how to listen on a port in Objective-C without pairing with the server?

提前感谢
Daniel

Thanks in advanceDaniel

推荐答案

查看CocoaAsyncSocket。它为您提供了一种良好且结构化的方式(使用代理)来发送和接收数据......还有多个客户端。文档非常好。

Check out CocoaAsyncSocket. It gives you a nice and structured way (with delegates) to send and receive data... also with multiple clients. The documentation is quite good. project link

编辑:查看无状态UDP连接的AsyncUdpSocket类。

edit: Have a look at the AsyncUdpSocket class for a stateless UDP connection.

这篇关于如何在Objective-C中侦听网络端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 03:47