1

I want to be able to have one ios-device that multiple ios-devices (is there any max?) are able to connect to and send data(a string in this case) to the first device.

I have tried this tutorial: http://www.raywenderlich.com/3932/networking-tutorial-for-ios-how-to-create-a-socket-based-iphone-app-and-server But I have a hard time understanding Objective-C

5
  • I am also on your way. I have succeded in sending messages to a server and could display those messages in Terminal. What is your status? Commented Dec 19, 2015 at 11:31
  • @Jess The same I think. I managed to send a string to a server, and the server send a string to any connected device! You can checkout my GitHub repository where I'm using it github.com/Totoajax/Alfons Commented Apr 9, 2016 at 10:30
  • I checked your git project. .xcodeproj file is missing. Commented Apr 11, 2016 at 4:12
  • @Jess I've uploaded it now :) Commented Apr 11, 2016 at 6:29
  • Good work done. I did the same using NSStream and swift. Commented Apr 11, 2016 at 6:50

1 Answer 1

2

Actually, for swift it will be the same as for objC. All you need is to port syntax from objC to swift:

func initNetworkCommunication() {
    var readStream : Unmanaged<CFReadStream>?;
    var writeStream : Unmanaged<CFWriteStream>?;
    CFStreamCreatePairWithSocketToHost(nil, "localhost", 80, &readStream, &writeStream);
    if let read = readStream {
        inputStream = readStream!.takeUnretainedValue()
    }
    if let write = writeStream {
       outputStream = writeStream!.takeUnretainedValue()
    }
}

and so on...

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.