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

Disconnecting with server immediately after connecting

I have written a Singleton Class using GCDAsyncsocket Library to establish connection with any other device having same service using Bonjour. On one device I am using its Method "startPublishing" to make it a Host(Server), from the Application on…
Mrug
  • 4,963
  • 2
  • 31
  • 53
4
votes
1 answer

Synchronize Asynchronous tasks in Objective-C

I'm trying to send some images file (almost 100MB) to my iDevice clients using GCDAsyncSocket. I want to Synchronously send packets to the clients. I mean after sending 100MB of data to first client iterating to the next client.but because of…
4
votes
1 answer

GCDAsyncSocket Client Public Key

I made a simple TLS Server with GCDAsyncSocket and want to get the clients public key. I tried using this: - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag { SSLContextRef ref = [sock sslContext]; …
thomasguenzel
  • 670
  • 7
  • 25
4
votes
1 answer

GCDAsyncSocket - Read stream never completes

I am playing with GCDAsyncSocket (MRC / iOS5.1) for a while, especially with "large" files (5 - 10 mb). Unfortunately sometimes the read stream is never completed (e.g. it gets stuck) just a few bytes at the end of the stream; the…
basvk
  • 4,437
  • 3
  • 29
  • 49
4
votes
1 answer

How to set tcp_nodelay in GCDAsyncsocket?

Seems like the title is self descriptive. I want to increase the speed of sending and receiving data in my app and i was told to set tcp_nodelay to true. But i have no idea how to do that with GCDAsyncSocket. Can anyone help me?
Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161
3
votes
1 answer

Swift example for GCDAsyncSocketDelegate

Refer to this post I have some issues while receiving data from GCDAsyncSocket and can't find a working Swift example. import UIKit import CocoaAsyncSocket class DiscoveryViewControllerTest: UIViewController, GCDAsyncSocketDelegate{ let host =…
PascalS
  • 975
  • 1
  • 16
  • 40
3
votes
1 answer

what different with GCDAsyncSocket and AsyncSocket?

One is GCD and other is Runloop?It is abstract,how to choose one for my TCP connect ?Very thankful,i only find how to use GCDAsyncSocket on github,but dont know how to choose one.
Kira
  • 243
  • 2
  • 9
3
votes
0 answers

GCDAsyncSocket multiple connections wont accept data from multiple sockets

I am trying to write an app that connects to multiple sockets at the same time, i'm having trouble with receiving data from the old socket when a new one is connected. The main thing is the delegate is not activated by the previously connected…
nsij22
  • 869
  • 10
  • 20
3
votes
0 answers

P2P UDP connection with STUN

Good day Everyone! I've been trying for quite a while to send packets p2p using UDP and GCDAsyncUDPSocket library. So i found an open source library to connect to STUN server and keep external port open. It works quite well and i've already had…
Morckovka
  • 103
  • 13
3
votes
0 answers

iOS GCDAsyncSocket Error: Domain=NSPOSIXErrorDomain Code=57

This is a weird one. I'm using GCDAsyncSocket and when I'm using the iOS simulator sometimes I can connect and send, no problem but sometimes when I try to connect and send something (writeData) I get the following error: didDisconnect Error…
Mavro
  • 571
  • 8
  • 19
3
votes
1 answer

GCDAsyncSocket lose data

when i use GCDasyncsocket to get socket Message from the server(java),it works in the ios simulator(xcode 6,iphone6+); but when i use my iphone6+ connect it to testing, it will lose data when it receive big data,details below i send a request to the…
3
votes
0 answers

GCDAsyncSocket never connects. Fails with "Error Code=60, Operation Timed Out"

I am really new to the Network Programming and trying to implement an app in iOS8/Swift using GCDAsyncSocket framework. I am able to publish the service from host device. The service is being found by the browser device but when the browser tries to…
Vik Singh
  • 1,563
  • 2
  • 19
  • 36
3
votes
1 answer

GCDAsyncSocket readData not called

I'm trying to send a message to a server and receive a response using my iPhone. I can connect to the server using: telnet 123.123.123.1 6000 Trying 123.123.123.1... Connected to 123.123.123.1. Escape character is '^]'. ?VERSION OK VERSION=PROTOCOL:…
Appdev
  • 33
  • 4
3
votes
1 answer

GCDAsyncSocket Multiple Connections?

I am already using GCDAsyncSocket to connect 2 devices. One broadcasting itself and accepting connection, the other one listening and requesting connection. If I try connect another device to the host still broadcasting, it connects then gets a…
JasonH
  • 93
  • 8
3
votes
3 answers

How to do multi-threading in iOS?

Sorry about the vague title of this question, I couldn't think of a concise sentence to explain the problem I'm having. Basically I want to start multiple threads and pass an object with thread-specific values that I can use within that context.…
1
2
3
13 14