Small sockets, autorelease etc PART II
Small sockets, autorelease etc PART II
- Subject: Small sockets, autorelease etc PART II
- From: malcom <email@hidden>
- Date: Sun, 26 May 2002 23:55:35 +0200
Hi again,
Wow thanx a lot to Brendan and Richard for the help!
Now it's all ok!
But when I try to call nslog to print the data...
2002-05-26 23:53:12.783 clIRC[397] data: \\304\\026\\010\\304
I think that's UNICODE...or no? How can I read well this line?
----------
This is the code (see the <<<<<<<<<< line)
----------
#import <Cocoa/Cocoa.h>
#import "Socket.h"
int main(int argc, const char *argv[])
{
Socket *socket;
NSString *stringa;
NSMutableData* response;
NSString* responseString;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NS_DURING
stringa = [NSString stringWithFormat:@"NICK daniele\n\rUSER dani . .
:ciao"];
// socket = [Socket socket];
socket = [[Socket alloc] init];
[socket connectToHostName: @"irc.edisontel.it" port: 6667];
[socket writeString: stringa];
response = [[[NSMutableData alloc] init] autorelease];
// [socket read
Data:response];
/* while ( [socket read
Data:response] )
{
// Read until other side disconnects
}*/
[socket read
Data:response];
responseString = [[[NSString alloc] initWith
Data:response
encoding:[NSString defaultCStringEncoding]]
autorelease];
NSLog(@"data: %s",responseString); <<<<<<<<<<<< THIS IS THE STRING
NS_HANDLER
NS_ENDHANDLER
return NSApplicationMain(argc, argv);
[pool release];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.