On Jun 15, 2011, at 2:30 PM, Jens Alfke wrote:

> On Jun 15, 2011, at 1:26 PM, Bing Li wrote:
> 
>> Actually, I attempt to design P2P system using Cocoa. Meanwhile, the peer on 
>> Mac OS X must communicate with some Java systems. So I need to use sockets 
>> and transmit XML.
> 
> Sorry to be blunt, but it’s clear from this answer (and others) that you’re 
> not reading the suggestions people are giving you. All you responded to here 
> was one minor question at the end of Conrad’s message, not the numbered list 
> of five major issues.

Not 100% sure, but I believe he may already have been told that he doesn't need 
to use low-level sockets just because he's communicating with Java...

Anyway, to Bing, my last advice:

- You have to follow proper memory management everywhere, not just where you're 
originally allocating objects. As has been pointed out to you multiple times 
now, your leak is not coming in the code snippet you posted. It's happening 
elsewhere, in code that uses the return value, so that's what you have to look 
at, what the consumers of that returned value do with it.

- Given that you had two stack-smashing bugs in one small snippet of C, and 
other oddities in the code, I think you really need to read a basic 
introductory text on C.

- You also don't seem to really understand how sockets work. Perhaps I'm wrong 
here, and your receivedMessage method does everything it would need to do in 
terms of assembling message fragments, if only you weren't potentially messing 
up strings because of boundary issues before you ever called it. (In other 
words, if you just appended to NSData or some such until you had a whole 
message.) But from the overall sense of your code and your questions, I really 
doubt it. So an introductory text on network programming is also in order 
(Stevens is the classic on this subject). Or you could use higher-level network 
APIs, to which I believe you were referred a long time ago: CFSocket, maybe 
NSURL depending on the structure of the messages you're exchanging with Java.


-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to