How to listen on a network port in Objective-C

I am trying to create an iPhone app that can listen to traffic on a specific network port.

The server on my network sends messages (different status messages for devices that are processed by the server) on a specific port.

My problem is that when creating 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 traffic on the specified port and then check for specific headers, and then use these messages. I know how to make a connection and talk to the server using write and read streams, but then I create a PairWithSocket and block the port for all other devices on the network.

Anyone who has suggestions on how to listen on a port in Objective-C without pairing with the server?

Thanks in advance Daniel

+4
source share
2 answers

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

edit: check out the AsyncUdpSocket class to connect without UDP authorization.

+4
source

I think this requires network support well below the socket API level, possibly at the hardware driver level, assuming packets are even routed to your device.

0
source

All Articles