WiTap Example in iPhone
This is the following piece of code from WiTap,
- (void) send:(const uint8_t)message
{
if (_outStream && [_outStream hasSpaceAvailable])
if([_outStream write:(const uint8_t *)&message maxLength:sizeof(const uint8_t)] == -1)
[self _showAlert:@"Failed sending data to peer"];
}
- (void) activateView:(TapView*)view
{
NSLog(@"ACTIVATE TAG: %d", [view tag]);
//[self send:[view tag] | 0x80];
[self send:[view tag]];
}
- (void) deactivateView:(TapView*)view
{
NSLog(@"DEACTIVATE TAG: %d", [view tag]);
//[self send:[view tag] & 0x7f];
[self send:[view ta开发者_StackOverflow中文版g]];
}
Is it possible to send a file using WiTap ? How to send NSData using the send method ?
Thanks
It is possible but it's the wrong way to do it. For what you're trying to do I recommend to use SimpleNetworkStreams (that's the name of the sample).
If you need to use multiple connection here's what you need http://developer.apple.com/samplecode/CocoaHTTPServer/index.html
精彩评论