xcode - Create a socket in Swift -


I am trying to write a simple echo server faster I have found examples or are either.

I failed in many things, I'll start from the top I high-level functions such as CFSocketCreate using could not manage to make a simple socket This is what I Finished:

  Class Ecorever: NSObject, NSSTrim Delegate {Private Server Server Socket: CFS ocket Rough? Func start () {self.serverSocket = CFSocketCreate (kCFAllocatorDefault, AF_INET, SOCK_STREAM, 0, 2, and self.acceptConnection, NSNull ())} func Accepted connection (socket: CFSocketRef, type: CFSocketCallBackType, address: CFDataRef, data Unsecured Pointer & lt; null & gt; info: unsafeMutablePointer & lt; zero & gt;) {// accept connection and stuff later}}  

I'm doing xcode for the new / objectivec / fast and I had a hard time coming to an error message to understand the above code

just leave me

EchoServer.swift: 31: 93: '(CFSocketRef, type Do: CFSo cketCallBackType, address: Am CFDataRef, data: UnsafePointer, Information: UnsafeMutablePointer) -> () '

I can not have its head or tail.

If anyone is looking for answers to this question. I had some typing problems in a slightly modified code callback, as well as it could not have any function on the class.

  import CoreFoundation function acceptConnection (socket: CFSocket!, Type: CFSocketCallBackType, address: CFData!, Data: UnsafePointer & LT; zero & gt;, Information: UnsafeMutablePointer & LT; zero & gt; ) {// accept connections and accessories later} Class Eicoserver: NSobies, NSSTrim Delegate {Private Server Server Socket: CFSOKRF? Function starts () {self.serverSocket = CFSocketCreate (kCFAllocatorDefault, AF_INET, SOCK_STREAM, 0, 2, acceptConnection, nil)}}  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Algorithm negotiation fail SSH in Jenkins -

java - Messages from .properties file do not display UTF-8 characters -