我在网站上找到这些代码,并将其重写为我现在的代码,我可以成功连接到服务器端。但我仍然遇到一些问题:
输出流:
根据网站上的代码,我可以正常发送字符串
- (IBAction)sendCmd:(id)sender
{
NSString *response = @"Hello World!";
NSData *data = [[NSData alloc] initWithData:[response dataUsingEncoding:NSASCIIStringEncoding]];
[outputStream write:[data bytes] maxLength:[data length]];
}
但我想发送字节,(例如0x80,0x10,0x20...等)Android语法是:
byte[] buf=new byte[10];
buf[0]=(byte) 0x80;
buf[1]=(byte) 0x10;
buf[2]=(byte) 0x20;
但是换了ios,不知道怎么办?给我一些建议或网站,感激不尽。