NetSocket question
NetSocket question
- Subject: NetSocket question
- From: André Lind <email@hidden>
- Date: Fri, 4 Feb 2005 10:20:44 +0100
Anyone who can help me with a small problem Im having with my NetSocket connection?
If I try to send files over my netsocket connection my program uses a *lot* of memory so I guess it loads
the entire file Im sending into memory...
Another problem is that I cannot use autorelease or release on any variables because then my i crashes completely.
Any ideas what to do?
Heres the code anyway if you want to take a look at it:
<x-tad-smaller> -(void)sendFile {
NSData *readData; readData = [outgoingHandle readDataOfLength:1024*16];
NSLog(@"Sending File");
[transferSocket writeData:readData];
}
- (void)netsocketConnected:(NetSocket*)inNetSocket {
[inNetSocket retain]; NSLog( @"FileTransfer: Connected" ); [self sendFile];
}
- (void)netsocket:(NetSocket*)inNetSocket connectionTimedOut:(NSTimeInterval)inTimeout { NSLog( @"FileTransfer: Connection timed out" );
}
- (void)netsocketDisconnected:(NetSocket*)inNetSocke t { NSLog( @"FileTransfer: Disconnected" ); }
- (void)netsocket:(NetSocket*)inNetSocket dataAvailable:(unsigned)inAmount {
NSLog(@"Incoming Data");
NSData *readData = [inNetSocket readData:inAmount];
NSLog(@"Writing Data");
[incomingHandle writeData:readData];
}
- (void)netsocketDataSent:(NetSocket*)inNetSocket { NSLog(@"Data sent");
[inNetSocket retain];
[inNetSocket scheduleOnCurrentRunLoop];
[self sendFile];
}
André</x-tad-smaller> _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden