iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
eggacher
V2EX  ›  iDev

有用GCDAsyncUdpSocket发送接收组播的么?

  •  
  •   eggacher · Jan 22, 2014 · 6589 views
    This topic created in 4525 days ago, the information mentioned may be changed or developed.
    //初始化响应socket
    self.responseSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self
    delegateQueue:dispatch_get_main_queue()];

    //绑定广播响应端口
    [self.responseSocket bindToPort:0xfaa5 error:&error];
    if (error) {
    NSLog(@"绑定响应端口%d失败%@",0xfaa5,error);
    }

    [self.responseSocket enableBroadcast:YES error:nil];
    if (error) {
    NSLog(@"开启组播%d失败%@",0xfaa5,error);
    }

    [self.responseSocket joinMulticastGroup:@"239.2.2.2" error:&error];
    if (error) {
    NSLog(@"开启加入组播%d失败%@",Port_Response,error);
    }

    //开始接收数据
    [self.responseSocket beginReceiving:&error];
    if (error) {
    NSLog(@"开始接收数据失败..%@",error);
    }

    组播地址改成224.0.0.1就可以接收到,改称239.2.2.2就不行了。
    iOS是不支持239.*.*.*这个地址么?
    1 replies    1970-01-01 08:00:00 +08:00
    eggacher
        1
    eggacher  
    OP
       Jan 23, 2014
    找到原因了,GCDAsyncUdpSocket默认设置TTL为1,值改大点就可以了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2310 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 00:32 · PVG 08:32 · LAX 17:32 · JFK 20:32
    ♥ Do have faith in what you're doing.