Wednesday, October 15, 2008

AsyncSocket for UDP

The famous TCP AsyncSocket class is now available in UDP form! It works almost exactly the same way, but is written specifically for UDP:

AsyncUdpSocket is a UDP/IP socket networking library that wraps CFSocket. It offers asynchronous operation, and a native cocoa class complete with delegate support. Here are the key features:

  • Queued non-blocking send/receive operations, with optional timeouts. You tell it what to send or receive, and it will call you when it's done.

  • Delicious cocoa style delegate support.

  • Written like a UDP library should be, using CFSocket and the runloop

  • Self-contained in one class. No need to muck around with CFSocket or BSD sockets. The class handles everything for you.

  • Support for IPv4 and/or IPv6


The AsyncUdpSocket should also work on the iPhone as well. Enjoy!

The code has been checked into the CocoaAsyncSocket Google Code Project.

 

5 comments:

matthias_kuhn@t-online.de said...

Hello,
I am searching the AsyncUDPSocket class. I can´t find it in the Google downloads You have linked.
Forgotten or obsolete ??
Please send me an answer soon, I have too code this over weekend.

With best regards Mathias Kuhn

Anonymous said...

You use subversion to checkout the latest version of AsyncUdpSocket. Just go here and copy-paste the one-liner that google gives you into your terminal.

GreyAreaUK said...

I'd like to open a UDP listening port on 514 (basically I want to write a custom Syslog monitor. Yes, I know Console.app can do this already) but I'm unable to openports below 1024 as (at a guess) they're privileged.

Any suggestions?

Many thanks.

Robbie Hanson said...

Yup, those ports are privileged, and require escalated permissions. I think you can write your app to prompt the user for an administrator password prior to starting the server. Take a look at apples "security" section in the core reference library.

AssA said...

Hello Deusty!

I'm trying to write a simple app that controls a full sized $10.000 robot, which is fully controlable by me and my MacBook.

This has to be a UDP Socket connection which sends commands to the robot. I found AsyncUdpSocket and implemented it into my iPhone App. On the simulator I can initialize a instance of that socket but as soon as I do this on the device, the app crashes.

Do you have any ideas what I could do?

I couldn't find your E-Mail, you said a lot of people send you an E-Mail. Might you help me (or someone else of course) a little bit?

The best would be a sample code. The robot has an open socket (listener I think) and I know the IP and the port. Now I have to send commands and to receive some.

Some sample code how establish a simple connection to a socket, which also works on the device would be awesome.

Please help me.

My E-Mail herefor is

gasparyan AT gmx DOT de

Please answer here and/or contanct me via my E-Mail

Thank you A LOT

Artur