SmallSockets
SmallSockets
- Subject: SmallSockets
- From: Chris Vincent <email@hidden>
- Date: Sat, 26 Oct 2002 23:33:13 -0500
Okay. I really need someone's help with SmallSockets. I'm using the
BufferedSocket class and am running a thread to grab data as it comes
in. That's where the problem lies. I can't seem to get the data
correctly. I've tried many many different ways of doing it. Sometimes
garbage characters come in after the regular ones, sometimes it's just
garbage characters and nothing else. I have no idea what's wrong. It
just seems like it should work, but it doesn't. Currently, I'm doing it
like this ("connection" being a BufferedSocket):
while(1) {
NSAutoreleasePool *apool=[[NSAutoreleasePool alloc] init];
NSMutableData *message = [NSMutableData alloc];
NSString *strMessage;
[message initWith
Data:[connection read
Data:[connection
bufferLength]]];
if(!message) break;
strMessage = [NSString stringWithUTF8String:[message bytes]];
if(strMessage) {
[owner receivedMessage:strMessage];
}
[message release];
[apool release];
}
That's the looping part of the thread. Doesn't it just look like it
should work? But it doesn't. It just gives me a bunch of garbage.
I've looked for hours on the net looking for good examples, but I've
failed to find one that does it right. I would super appreciate any
help with this very frustrating little problem.
"Someone is sitting in the shade today
because someone else planted a tree a hundred years ago."
- Unknown
~ Dris ~
- Random Signature #14 -
_______________________________________________
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.