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.
11 comments:
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
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.
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.
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.
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
Hello,
I have implemented AsyncUDPSocket in my code.
It send the data perfectly to the UDP server but it never calls didReceiveData deleget method.
I am receiving the data on server side properly and send back data to the client instantly but it dint work.
Please help me. It is really really urgent for me.
Thanks.
Nish,
Just as you need to call socket.read() with traditional sockets, you must call [socket readDataWithTimeout:] with AsyncUdpSocket.
AsyncUdpSocket was designed to work around your schedule (as opposed to you working around it). It will read data for you, but only when you're ready for it. So call readDataWithTimeout when you're ready.
If you just want a constant stream of data, then invoke readDataWithTimeout again within the onSocket:didReadData: delegate callback method.
Hello,
I want to send data from my IPhone to a Windows system.
It is sufficient for me, when Im using UDP as IP.
Is that enough when I try to send the data with sendto(sock, [data bytes], [data length], 0, addrPtr. addrLen) without AsyncUDPsocket (just sys/socket.h)? Need I an excisting connection for sendto()?
What is with Bonjour on the Windows site? I need it only if I want a peer-to-peer connection, or did I need it for UDP too?
Best regards
Oliver
Love your work!!
Will there be a GCD AsyncUDPSocket variant in the near future?
Thanks!
bob.
@bob
Yup, working on it now.
I'm using the GCDAsyncUdpSocket class for multicast receive and it seems to have inherited an old bug from the non-GCD class.
When receiving udp multicast packets, two packets show up on receive for each packet sent. Each duplicate packet has an IPv6 address as its source address. Packet trace over the air shows that only one packet is being sent, with an IPv4 address.
The workaround is to disable IPv6 after creating the socket, then it works fine and the duplicates no longer appear.
Is it a bug, or perhaps a feature?
Regards,
David
Post a Comment