Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
713 views
in Technique[技术] by (71.8m points)

objective c - What is the iOS equivalent to Android Socket programming code?

I have some socket programming code in Android (Java) and I want to implement the same thing in iOS (Objective-C).

On iOS, NSStream, NSInputStream, NSOutputStream are some of the classes for socket programming.

I have doubts when comparing them to some methods on Android's SocketChannel class.

socketChannel.configureBlocking
socketChannel.setSoTimeout
socketChannel.connect 
socketChannel.finishConnect
socketChannel.isConnected

What are the equivalent methods in iOS classes like NSStream, NSInputStream?

And also ByteBuffer on Android has a position() method. What is the equivalent method in iOS?

I know the NSStream constants are there, but I am confused about how they map to Android code. Could you please suggest which methods are equivalent in iOS?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You don't translate code line by line. Different platforms and even different frameworks use different styles of API.

Since your question doesn't say what you are trying to do, I can only recommend that you read more about how stream and socket programming works on iOS in


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...