Reputation: 1220
I have a little MAC OS X Application that should send a UDP Datagram to a server.
I want to use the cocoa asyncudpsockets (http://code.google.com/p/cocoaasyncsocket/) to do this, but i have the problem that i call the "sendData" method but nothing happens.
[socket sendData:[NSData dataWithBytes:stream length:length]
toHost:host
port:(uint16)port
withTimeout:5
tag:1];
stream is a Byte* contains the datagram host is a ip-address as NSString.
Can anybody help me?
Upvotes: 2
Views: 719
Reputation: 1300
Did you correctly set the delegate ?
[socket setDelegate:self];
Then :
[socket connectToHost:(NSString *)host
onPort:(UInt16)port
withTimeout:(NSTimeInterval)timeout
error:(NSError **)errPtr];
Then in the delegate method :
- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port
{
[sock writeData:[NSData dataWithBytes:stream length:length] withTimeout:TIMEOUT_NONE tag:TAG_HEADER];
}
Hope it will help ;-)
Upvotes: 1