JamesM
JamesM

Reputation: 13

Connect Swift iOS client to Netty Server

I am currently going about connecting an iOS application written in swift to my Java server using Netty.io. I was wondering if this is possible? And if so, is there any available resources with which I can learn? However, if it is not possible, I was wondering if any form of NIO / non blocking io can be used to connect the iOS with the Java server? I cannot change the language on which the server was written. Thanks in advance for any help

Upvotes: 1

Views: 1608

Answers (2)

hcarrasko
hcarrasko

Reputation: 2352

Sure, you can. To you Netty server you could connect any client that supports you server protocol. To do it I recommend you this library SwiftSocket

For example:

var client:TCPClient = TCPClient(addr: "www.apple.com", port: 80)
var (success,errmsg)=client.connect(timeout: 1)
if success{
    var (success,errmsg)=client.send(str:"GET / HTTP/1.0\n\n" )
    if success{
        var data=client.read(1024*10)
        if let d=data{
            if let str=String.stringWithBytes(d, length: d.count, encoding: NSUTF8StringEncoding){
                println(str)
            }
        }
    }else{
        println(errmsg)
    }
}else{
    println(errmsg)
}

Hope it helps.

Upvotes: 0

Rustam
Rustam

Reputation: 1407

I think iOS application sends/receives regular bytes as any other application. So you can connect from iOS to Java (or any other) server, that supports your protocol. With Netty you can develop ant http/binary protocol you want.

Upvotes: 0

Related Questions