iOS CocoaAsyncudpSocket:从客户端CocoaAsyncudpSocket发送mp3数据,但未发送最大数据

iOS CocoaAsyncudpSocket:从客户端CocoaAsyncudpSocket发送mp3数据,但未发送最大数据,ios,objective-c,iphone,Ios,Objective C,Iphone,我正在尝试向服务器应用程序发送mp3数据。我在客户端按照下面的代码发送UIImage数据。但是,问题是,它没有将此mp3数据发送到服务器前端应用程序。我发送的小mp3(2kb)比发送的大mp3(50mb)不发送服务器如何解决此问题请帮助 代码: -(iAction)发送:(id)发送方 { NSString*host=addrField.text; 如果([主机长度]==0) { [自日志错误:@“需要地址”]; 返回; } int port=[portField.text intValue];

我正在尝试向服务器应用程序发送mp3数据。我在客户端按照下面的代码发送UIImage数据。但是,问题是,它没有将此mp3数据发送到服务器前端应用程序。我发送的小mp3(2kb)比发送的大mp3(50mb)不发送服务器如何解决此问题请帮助

代码:

-(iAction)发送:(id)发送方
{
NSString*host=addrField.text;
如果([主机长度]==0)
{
[自日志错误:@“需要地址”];
返回;
}
int port=[portField.text intValue];
如果(端口65535)
{
[自日志错误:@“需要有效端口”];
返回;
}
NSString*msg=[[NSBundle mainBundle]路径为资源:@“rr2”,类型为:@“mp3”];
如果([msg长度]==0)
{
[自日志错误:@“需要消息”];
返回;
}
NSData*data=[[NSData alloc]init];
data=[NSData dataWithContentsOfFile:msg];
udpSocket=[[GCDAsyncUdpSocket alloc]initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
//省略错误检查
[udpSocket enableBroadcast:是错误:无];
[udpSocket bindToPort:端口错误:nil];
[udpSocket joinMulticastGroup:主机错误:nil];
[udpSocket开始接收:无];
[udpSocket sendData:data to host:host port:port with timeout:-1标记:1];
//tag++;
}

UDP协议对可发送的最大数据量有限制。在此库中,IPv4设置为65535。检查您的数据是否超过此限制。如果未按如下方式将限制设置为最大值:-

[udpSocket setMaxReceiveIPv4BufferSize:maxValue]


max4ReceiveSize=9216;max6ReceiveSize=9216;这是默认限制。你可以增加它。你的歌曲数据总共有多少?如果更多,我建议使用TCP协议。我增加它。但没有任何影响歌曲数据是多少?30mb歌曲和此歌曲转换nsdata后的nsdata大小是6054586字节。
- (IBAction)send:(id)sender
{
NSString *host = addrField.text;

if ([host length] == 0)
{
    [self logError:@"Address required"];
    return;
}

int port = [portField.text intValue];
if (port <= 0 || port > 65535)
{
    [self logError:@"Valid port required"];
    return;
}


NSString *msg = [[NSBundle mainBundle] pathForResource:@"rr2" ofType:@"mp3"];


if ([msg length] == 0)
{
    [self logError:@"Message required"];
    return;
}



NSData* data =[[NSData alloc]init];
data= [NSData dataWithContentsOfFile:msg];

udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self  delegateQueue:dispatch_get_main_queue()];

//omitted error checking

[udpSocket enableBroadcast:YES error:nil];
[udpSocket bindToPort:port error:nil];
[udpSocket joinMulticastGroup:host error:nil];
[udpSocket beginReceiving:nil];
[udpSocket sendData:data toHost:host port:port withTimeout:-1 tag:1];



//tag++;


}