cocoaasyncsocket

CocoaAsyncSocket and reading data from a socket

不羁的心 提交于 2019-12-09 13:01:29
问题 On my TCP-socket based server, I send a packets over the stream where packets consist of a header specifying the number of bytes in the packet, followed by that number of bytes. For those familiar with Erlang, I'm simply setting the {packet, 4} option. On the iOS side, I have code that looks like this, assuming I want to figure out the size of the stream for this message: [asyncSocket readDataToLength:4 withTimeout:-1 tag:HEADER_TAG]; That works fine and the following delegate method callback

Is it possible to build socket connection between 2 iOS devices

南笙酒味 提交于 2019-12-09 06:53:07
问题 Is it possible to build a socket connection between 2 iOS devices connected to the same network (Without net)? if it's possible .. Is (CocoaAsyncSocket project) useful for me? I just want to send a message from Device A to Device B which put the app in background .. when Device B receive the message should show notification to return the app to foreground. It's not for the App Store, so I don't care if Apple would reject the app because of this behavior. 回答1: Yes , you can do it, and yes ,

Retrieving a string from a UDP server message

孤人 提交于 2019-12-08 03:17:09
问题 I'm using the CocoaAsyncSocket library in my Swift-based iOS app. I have created an async UDP socket to a UDP server on my network, and it sends back a reply. I'm reading this reply like this: func udpSocket(sock: GCDAsyncUdpSocket!, didReceiveData data: NSData!, fromAddress address: NSData!, withFilterContext filterContext: AnyObject!) { println("didReceiveData") let data = address var host: NSString? var port1: UInt16 = 0 GCDAsyncUdpSocket.getHost(&host, port: &port1, fromAddress: address)

CocoaAsyncSocket doesn't work after being in background

空扰寡人 提交于 2019-12-07 22:19:07
问题 I have an instance of AsyncSocket which I've been using as a server on an iPad, and then an AsyncSocket socket running on another iPad which is acting as the client. I have all the necessary code to exchange data between the client and server -- there are no issues there. The problem I'm experiencing is that it all works fine, but during bug testing of my app I have noticed one particularly strange (and irritating issue): If I turn off the server iPad (at which point none of the socket's

NSPOSIXErrorDomain when binding to socket on macOS 10.12

戏子无情 提交于 2019-12-05 21:46:05
I am playing with CocoaAsyncSocket in Swift to bind to a UDP socket and receive messages over the local network. I am initialising a socket, and trying to bind to a port but am getting a NSPOSIXErrorDomain error. Perhaps indicating some sort of permissions issue? My code: import Cocoa import CocoaAsyncSocket @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate, GCDAsyncUdpSocketDelegate { func applicationDidFinishLaunching(_ aNotification: Notification) { let socket = GCDAsyncUdpSocket.init(delegate: self, delegateQueue: DispatchQueue.main) do { try socket.bind(toPort: 53401)

I am looking for some examples on GCDAsyncUdpSocket, but found none that works

馋奶兔 提交于 2019-12-05 03:13:46
问题 didReceiveData was never called - I coded this swift class which was called by my mainline UIViewController to send out a message to the server which received it OK, but when the server sent a response back, the client never receives it because the didReceiveData() was never triggered. I kept googling and look at the doc, and it said that the client does NOT need to bind (Only the server needs doing this) Can anyone help me with this - Thanks in advance. import UIKit import CocoaAsyncSocket

Is it possible to build socket connection between 2 iOS devices

我只是一个虾纸丫 提交于 2019-12-03 09:41:45
Is it possible to build a socket connection between 2 iOS devices connected to the same network (Without net)? if it's possible .. Is (CocoaAsyncSocket project) useful for me? I just want to send a message from Device A to Device B which put the app in background .. when Device B receive the message should show notification to return the app to foreground. It's not for the App Store, so I don't care if Apple would reject the app because of this behavior. Nate Yes , you can do it, and yes , CocoaAsyncSocket would be useful. If you don't have to worry about the carrier network's firewalls and

Showing Waiting Alert View At Load

删除回忆录丶 提交于 2019-12-02 07:40:06
问题 I would like when my app starts for it to show an Alert view for about 5 seconds, then depending on the outcome of a background process, it will show another Alert view. The problem I am experiencing is that when I try to use Sleep to wait for a background process to occur. The first Alert does not show and wait the 5 seconds. The app shows the first view of the app, and then after 5 seconds the first Alert shows briefly. What do I need to do to perform what I wish. Here is my code. - (void

Showing Waiting Alert View At Load

…衆ロ難τιáo~ 提交于 2019-12-02 07:26:06
I would like when my app starts for it to show an Alert view for about 5 seconds, then depending on the outcome of a background process, it will show another Alert view. The problem I am experiencing is that when I try to use Sleep to wait for a background process to occur. The first Alert does not show and wait the 5 seconds. The app shows the first view of the app, and then after 5 seconds the first Alert shows briefly. What do I need to do to perform what I wish. Here is my code. - (void)viewDidAppear:(BOOL)animated { SSGlobalSettings *connSettings = [SSGlobalSettings sharedManager];

GCDAsyncSocket with Client Authentication

送分小仙女□ 提交于 2019-12-01 04:22:22
I have been using CocoaAsyncSocket to send data to our server without SSL. Now the server side has implemented SSL/TLS with client authentication. TO implement this in our app I was given the following three files: ca-chain.cert.pem client-test.cert.pem client-test.key.pem I converted the files to iOS readable formats as below: ca-chain.cert.pem to ca-cert.cer client-test.cert.pem to client_cert.cer client-test.key.pem to client_key.p12 I have got it working till SSL. But having trouble with Client Authentication. Here is my code: didConnectToHost: - (void)socket:(GCDAsyncSocket *)sock