Considering the following code:
Code:
NSURL *website = [NSURL URLWithString:urlStr];
CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)[website host], 80, &readStream, &writeStream);
NSInputStream *inputStream = (NSInputStream *)readStream;
NSOutputStream *outputStream = (NSOutputStream *)writeStream;
I can't find any mention in the docs, whether this method creates UDP connections or TCP connections. I guess it's TCP, and I need UDP.
Also, I frequently need to change the output destination port. Is there a way to do it? I think holding one NSOutputStream for each port I want to send to is kinda absurd...
I have a hunch I will be more lucky with CFSocketCreateConnectedToSocketSignature and CFSocketSendData (although I prefer using the NSStream classes, as it seems more comfortable), but I just can't find a good example of it used with UDP.
I guess I'm not the first one to mess around with UDP in iOS, so, anyone?