Questions tagged [gcdasyncsocket]

GCDAsyncSocket is a TCP socket library built upon Grand Central Dispatch. The project also contains a !RunLoop based version, as well as UDP socket libraries.

GCDAsyncSocket and AsyncSocket are TCP/IP socket networking libraries. Here are the key features available in both:

Native objective-c, fully self-contained in one class. No need to muck around with sockets or streams. This class handles everything for you. Full delegate support Errors, connections, read completions, write completions, progress, and disconnections all result in a call to your delegate method. Queued non-blocking reads and writes, with optional timeouts. You tell it what to read or write, and it handles everything for you. Queueing, buffering, and searching for termination sequences within the stream - all handled for you automatically. Automatic socket acceptance. Spin up a server socket, tell it to accept connections, and it will call you with new instances of itself for each connection. Support for TCP streams over IPv4 and IPv6. Automatically connect to IPv4 or IPv6 hosts. Automatically accept incoming connections over both IPv4 and IPv6 with a single instance of this class. No more worrying about multiple sockets. Support for TLS / SSL Secure your socket with ease using just a single method call. Available for both client and server sockets. GCDAsyncSocket is built atop Grand Central Dispatch:

Fully GCD based and Thread-Safe It runs entirely within its own GCD dispatch_queue, and is completely thread-safe. Further, the delegate methods are all invoked asynchronously onto a dispatch_queue of your choosing. This means parallel operation of your socket code, and your delegate/processing code. The Latest Technology & Performance Optimizations Internally the library takes advantage of technologies such as kqueue's to limit system calls and optimize buffer allocations. In other words, peak performance. AsyncSocket wraps CFSocket and CFStream:

Fully Run-loop based Use it on the main thread or a worker thread. It plugs into the NSRunLoop with configurable modes.

For more information follow these links:

  1. https://github.com/robbiehanson/CocoaAsyncSocket
  2. https://github.com/darkseed/cocoaasyncsocket/wiki/Reference_GCDAsyncSocket
204 questions
0
votes
1 answer

GCDAsyncSocket readDataWithTimeout is not continuing to read data

I am using GCDasyncsocket in my iOS app to send a string over a socket connection and then to read a string every second over the same socket connection. I am also creating a second socket to the same server on a different port ad reading once a…
0
votes
1 answer

GCDAsyncSocket Delegate Calls Not Working

I am having a problem that is the exact same as This problem someone posted on github. GCDAsyncSocket won't connect unless I add [NSThread sleepForTimeInterval:0.1] In the last post of the thread this was posted I think I solved this and as I…
Joel
  • 1,585
  • 2
  • 10
  • 20
0
votes
1 answer

GCDAsyncSocket Swift Xcode 6.2 - Cant make up its mind

I"m trying to instantiate a GCDAsyncSocket connection in Swift and running into a CRAZY error. var socket : GCDAsyncSocket? typealias dispatch_queue_attr_t = NSObject var socketQueue = dispatch_queue_create("socketQueue", DISPATCH_QUEUE_SERIAL) …
Jeef
  • 26,861
  • 21
  • 78
  • 156
0
votes
0 answers

Send Data to a multicast socket using GCDAsyncUDPSocket in local network

Im working in an app where you suscribe to a multicast socket to listen to other devices that post to that socket. When listening everything is working fine. The problem is when I try to post to that socket in a local network. It says "Network…
0
votes
1 answer

GCDAsyncSocket in Swift with compile error

I want to use GCDAsyncSocket in Swift, but get the "unresolved identifier 'GCDAsyncSocket'" compiler error. I have imported GCDAsyncSocket.framework but I can't get rid of this error.
user2056962
  • 85
  • 1
  • 1
  • 7
0
votes
1 answer

Creating p2p connection iOS

Okay. So I have been trying to connect devices p2p with streams for a week. Still no result and i am getting crazy and desperate. Please Don't send me to Ray Wenderlich tutorial and GCD wiki or to CFStream Guide as i have surfed it to the holes. So…
Morckovka
  • 103
  • 13
0
votes
1 answer

gcdasyncsocket background file transfer

Having two devices that need to keep transferring data while in background or in LockScreen. The main resource about backgrounding is available on…
Lookaji
  • 1,023
  • 10
  • 21
0
votes
1 answer

GCDASyncScocket readDataToLength: with swift

I am trying to implement an app using GCDAsynSocket framework with Swift. I am stuck at GCDASyncSocket's readDataToLength method. In objective c, we use to write it as following: [socket readDataToLength:sizeof(uint64_t) withTimeout:-1.0…
Vik Singh
  • 1,563
  • 2
  • 19
  • 36
0
votes
0 answers

GCDAsyncUDPSocket WiFi interruptions on IOS 8 when Control Center slides up?

This sounds really odd, but I'm wondering if anyone else has run into this situation on IOS 8. I have an app that receives low latency audio via UDP using GCDAsyncUdpSocket, and it receives about a 200 byte packet every 20ms. Works great in the…
Chuck D
  • 313
  • 2
  • 13
0
votes
1 answer

How GCDAsyncSocket has identified end of an incoming message

It easy to understand that we can use following ways to identify the end of an incoming message, for example: 1. Putting the length of the message before the data itself 2. Using a separator However, GCDAsyncSocket provides a more…
ikzjfr0
  • 767
  • 1
  • 7
  • 14
0
votes
1 answer

Debug Packet Loss In TCP Communication in iOS/iPad Application

I have an iOS application that remotely connects to 3 sockets(of some hardware). Each Socket has its own priority. One channel is only used for transferring messages between iPad App & hardware, one for Tx/Rx Images, another one for Tx/Rx Videos. I…
Pranav Jaiswal
  • 3,752
  • 3
  • 32
  • 50
0
votes
1 answer

Block dispatch_queue until it sends the entire data

I am trying to send some hexadecimal packets that create a waveform at the server side in objective c by creating a tcp/ip connection.My problem is that i am able to send the data and can also see the waveform at the server side.But what happens is…
0
votes
2 answers

Getting Response from TCP server on Swift client

I am trying to write a TCP socket client in swift using GCDAsyncSocket, but I have one problem. In my code I have a NSTextField (called box) and here is my code: import Cocoa class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak…
Marzukr
  • 95
  • 3
  • 11
0
votes
1 answer

A (weakly protected) secure server using GCDAsyncSocket

I'm trying to use GCDAsyncSocket to write a weakly protected server (i.e. something I would be able to connect to using an anon cipher). What I'm currently doing is the following: Bind to a port and start listening ... BOOL result = [serverSocket…
pb593
  • 91
  • 5
0
votes
1 answer

iOS: GCDAsyncSocket and its tag

In my app I'm using GCDAsyncSocket and I write and read in this way: NSData *bufferWriteData = [NSData dataWithBytesNoCopy:bufferWrite length:17 freeWhenDone:YES]; [self.socket writeData:bufferWriteData withTimeout:-1 tag:1]; [self.socket…
cyclingIsBetter
  • 17,447
  • 50
  • 156
  • 241