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
3
votes
1 answer

iOS - No stack trace when calling dispatch_async

I've created some example code to demonstrate my problem. - (void) test { void (^handler)(void) = ^ { NSArray *test = [NSArray array]; [test objectAtIndex: 5]; }; handler = [handler copy]; …
SukyaMaki
  • 173
  • 1
  • 1
  • 5
3
votes
1 answer

GCDAsyncSocket with SSL

I run a Java server which accepts Socket or SSLSocket connections (different ports). On the client side I use in my iPhone app the GCDAsyncSocket to connect to the server. Which works fine if I use the insecure version (no SSL). Now I try to connect…
user2698705
  • 51
  • 1
  • 4
3
votes
2 answers

"Connection reset by peer" errors with GCDAsyncUdpSocket on iOS6

I am having a problem with using GCDAsyncUdpSocket. I am using the iPad as a user interface app that interacts with another app - call it Host, the latter running on a separate Windows machine. Both machines are on their own private network, so…
Bob
  • 587
  • 8
  • 17
3
votes
3 answers

Why is GCDAsyncSocket readData designed to read only once?

One thing I found unintuitive about GCDAsyncSocket's didReadData callback is that it doesn't get call again unless you issue another readData. Why is it designed this way? Is it correct to expect the user of the library to initiate another read…
Boon
  • 40,656
  • 60
  • 209
  • 315
3
votes
2 answers

GCDAsyncUdpSocket immediately closes when sending to an IPv6 address

I'm connecting via UDP to a server on a different device which is advertised by Bonjour. When both the iOS device which this code is running on, and the server, are on our wifi network it works just fine because the bonjour service resolves to a…
alisonc
  • 115
  • 1
  • 8
3
votes
0 answers

GCDAsyncSocket not connecting or giving me error to know it failed

I am trying to use the GCDAsyncSocket class to connect to a device but am having trouble. It seems to fail to inform me if it connects, but also fails to inform me it failed to connect. Here is my .h file #import #import…
user1331999
3
votes
1 answer

GCDAsyncSocket tag parameter

I'm wondering how to use the tag parameter in methods such as readDataWithTimeout: tag: writeData: tag: What happens if I want to use the tag to identify the type of packet ? For example is I say tag == 2 means that the packet is a message from a…
rmonjo
  • 2,675
  • 5
  • 30
  • 37
2
votes
0 answers

Cannot allocate memory error using GCDAsyncSocket

I'm trying to upload videos to a server via TCP/IP using GCDAsyncSocket. Sometimes, the socket disconnects with an error that I haven't been able to eliminate: 2011-12-17 11:39:25.073 Hadza[433:707] socketDidDisconnect, error: Error…
2
votes
1 answer

Error while binding a socket : NSPOSIXErrorDomain Code=1 "Operation not permitted"

I'm trying to implement GCDAsyncSocket to mac os x (Mojave 10.14.3) application to listen data from localhost:port. The problem is no matter what port I choose I always get this error: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not…
Jeavie
  • 212
  • 4
  • 16
2
votes
1 answer

GCDAsyncSocket with bonjour Service: does startTLS initiate TLS handshake

I trying to encrypt peer to peer communication using TLS handshake which uses startTLS method of GCDAsyncSocket library. Bonjour services are published by server and client connects to published host name. After the socket connection is established…
Gyanendra
  • 361
  • 2
  • 15
2
votes
0 answers

GCDAsyncSocket authentication client self signed certificate

I am developing an SSL socket server using the GCDAsyncSocket. I would like to know if is possible validate the client certificate or an equivalent function like setNeedClientAuth in Java?
Jorge B.
  • 1,144
  • 2
  • 17
  • 37
2
votes
1 answer

GCDAsyncSocket startTLS does not work

I am able to connect to the desired socket with IP and port. - (void)socket:(GCDAsyncSocket *)sender didConnectToHost:(NSString *)host port:(UInt16)port { [sender startTLS:nil]; if(self.createTCPSocketHelperDelegate &&…
Ashish
  • 923
  • 2
  • 11
  • 16
2
votes
2 answers

Corrupt Protocol Buffers Messages

I am using Protocol Buffers for Swift (latest from CocoaPods) and Google's official Java Protocol buffer client (version 2.6.0) to to pass messages between a Java server (ServerSocket) and a Swift iOS app (GCDAsyncSocket). Most messages (several…
closeparen
  • 276
  • 2
  • 11
2
votes
0 answers

Socket closed by remote peer Error when server disconnected in iOS

I am using GCDAsyncSocket for connecting to socket. App works fine till phone gets lock. When phone gets unlock then socketDidDisconnect gets call with error (Socket closed by remote peer). there I am reconnecting to server but socket gets…
M Swapnil
  • 2,361
  • 3
  • 18
  • 33
2
votes
0 answers

GCDAsyncUdpSocket, how to know when you don't receive data

I'm working on an iOS application. I have a target that will send me a response anytime I send it data. I've implemented GCDAsyncUdpSocket and I can send and receive data without a problem. I would like to handle the case when data is not sent back…
Ben Adams
  • 21
  • 2
1 2
3
13 14