Hi all and thx for your attention,
I'm from Switzerland, so please forgive my english errors

!
I'm trying to communicate with a java server on a PC from my iPhone. I use actually the smallsocket wrapper (
http://smallsockets.sourceforge.net/) but have tried to do it with this sample of code :
Code:
-(IBAction) connect_button {
CFWriteStreamRef writeStream = NULL;
CFStringRef host = CFSTR("X.X.X.X");
UInt32 port = X;
CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, host, port, NULL, &writeStream);
CFWriteStreamSetProperty(writeStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
if(!CFWriteStreamOpen(writeStream)) {
NSLog(@"Error Opening Socket");
}
else{
UInt8 buf[] = "Hello WOrld!";
int bytesWritten = CFWriteStreamWrite(writeStream, buf, strlen((char*)buf));
NSLog(@"Written: %d", bytesWritten);
if (bytesWritten < 0) {
CFStreamError error = CFWriteStreamGetError(writeStream);
/** How do I print out description? All i get is -1 here. i.e What is perror() equivalent? **/
}
}
CFWriteStreamClose(writeStream);
}
This is my code with smallsocket :
Code:
-(BOOL) connectionTo:(NSString*)host port:(int)port {
socket = [Socket socket];
@try{
[socket connectToHostName:host port:port];
[socket writeString:@"Hello World!"];
[socket retain];
}
@catch (NSException* exception) {
NSLog(@"socket error");
socket = nil;
[socket release];
return NO;
}
//** Disconnect **//
[socket close];
return YES;
}
In both case, if I don't write the red lines, my server receives the data only when I quit the iphone app... If i close the stream or the socket, it'll receive the data immediately... but I don't want to close it... Is there something wrong in my code that I omitted ?
Thx for reading and for your comment if you have any idea

about that !