Hi friends,
need some help:
I have created a mutable array of ASCII- strings (21 per Key), which I like to transfer to a socket by using CFStream. Each string represents a key stroke (1 of 8).
Here is the code, I'm using:
// socket- initialising: for writestream, host, port, buf
static CFWriteStreamRef writeStream = NULL;
static CFStringRef host = CFSTR("192.168.100.1");
static UInt32 port = 5100;
static UInt8 buf[] = "123456789012345678901";
// Initialising the NSMutably array of in total 8 Key- Strings-Strings
ListOfTastenStrings = [[NSMutableArray alloc] init];
[ListOfTastenStrings addObject:@"at+xcply00\n\r000000000"]; // Index 0, Key 1
[ListOfTastenStrings addObject:@"at+xcsto00\n\r000000000"]; // Index 1, Key 2
[ListOfTastenStrings addObject:@"at+xcffd00\n\r000000000"]; // Index 2, Key 3
[ListOfTastenStrings addObject:@"at+xcrew00\n\r000000000"]; // Index 3, Key 4
[ListOfTastenStrings addObject:@"at+xrw01=00\n\r00000000"]; // Index 4, Key 5
[ListOfTastenStrings addObject:@"at+xrw02=00\n\r00000000"]; // Index 5, Key 6
[ListOfTastenStrings addObject:@"at+xrw03=00\n\r00000000"]; // Index 6, Key 7
[ListOfTastenStrings addObject:@"at+xrw04=00\n\r00000000"]; // Index 7, Key 8
// Here should be the code, which transfers one of the 8 string objects into my buffer "buf"
??, does somebody know?
// Here is the code, which is sending the content of the buffer "buf" to the host
- (IBAction) StringFromKey7:(id)sender
{
CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, host, port, NULL, &writeStream);
CFWriteStreamOpen(writeStream); CFWriteStreamWrite(writeStream, buf, strlen((char*)buf)); CFWriteStreamClose(writeStream); CFRelease(writeStream); }