Re: More NetSocket problems...
Re: More NetSocket problems...
- Subject: Re: More NetSocket problems...
- From: André Lind <email@hidden>
- Date: Tue, 1 Feb 2005 12:58:23 +0100
Ok, but isnt it just that what Im doing? Or it intended that way anyway... How do I add a RunLoop iteration to use "in between"?
Found out that it doesnt use all my CPU but quite a lot :/
Seems like it read all the Data to memory... how can I stop it from doing that and just send it to the reciever direct?
Thanks for all help :)
2005-02-01 kl. 02.57 skrev Agent M:
The problem here is that you don't understand the asynchronous nature of NetSocket. By calling writeData without any runloop iterations in between, you are effectively bringing the whole file into memory and then sending it. Instead, send a block of the file every time you get the DataSent message called. This will maximize the throughput while minimizing unnecessary caching. Good luck with your project.
On Jan 31, 2005, at 5:47 PM, André Lind wrote:
Ok, got my NSFileHandles to work, over to my next problem :(
My program is sending and the other one is recieving and everything is a-ok :D
BUT... if I just nudge my mouse or do anything on my sending computer the socket disconnects...
The filetransfer takes all of my CPU it can... not good :/
This is how I did but i dont know if its the best way (probobly not):
- (void)netsocketDataSent:(NetSocket*)inNetSocket
{
NSLog(@"Data sent");
[self sendFile];
}
-(void)sendFile
{
NSData *readData;
readData = [outgoingHandle readDataOfLength:1024*16];
[transferSocket writeData:readData];
}
-(id)init
{
outgoingHandle = [[NSFileHandle fileHandleForReadingAtPath:@"Filename"] retain];
}
Anyone know what to do about this? The netsocket uses currentRunloop, maybe its that?
I really dont know what to do about this problem :(
André
_______________________________________________
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