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

Reading complex socket responses

I have a code design question, I'm having trouble thinking of the most efficient manner to handle this: Basically, I want to send a JSON request and read the response back from the server in one go. I have a methods such…
khaliq
  • 3,125
  • 4
  • 17
  • 23
2
votes
1 answer

GCDAsyncSocket for iOS is not writing out the buffer

Basically I write an NSData object: [asyncSocket writeData:JSONRequestData withTimeout:-1 tag:1]; Which when run, invokes the delegate - (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag But for some reason, when the write goes to…
khaliq
  • 3,125
  • 4
  • 17
  • 23
2
votes
1 answer

How to separate data packets when using GCDASyncSocket

Can anyone help me? I intensively exchange data between two devices over TCP protocol by using GCDAsyncSocket. I send data like this: NSMutableDictionary *packet = [[[NSMutableDictionary alloc] init] autorelease]; [packet…
Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161
2
votes
1 answer

Issue with GCDAsyncSocket in Mountain Lion

I am having an issue using the GCDAsyncSocket class in my Mac (Objective-C) application. Here is the error I get: Apple Mach-O Linker (Id) Error Ld "/Users/matthewdahl/Library/Developer/Xcode/DerivedData/Server_Tester-fkkcdricfunsmwcdnerorqdtqetc/ …
user1331999
2
votes
2 answers

How to use GCDAsyncUdpSocket for multicast over wifi and bluetooth

I am currently using GCDAsyncUdpSocket to send multicast datagrams over wifi between iOS devices. The Code is pretty simple.. Client self.socket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self …
RyanM
  • 4,474
  • 4
  • 37
  • 44
2
votes
0 answers

GCDAsyncUdpSocket UDP communication over internet

I have a problem using GCDAsyncUdpSocket over internet. Everything works fine when I am doing test on my local computer. I try to to send UDP message between a computer connected to internet with a 3G key and an Ipod connected through wifi.…
2
votes
1 answer

SOCKS5 connection times out (GCDAsyncSocket). (OpenFire, XEP-0065 and iOS XMPPFramework)

Problem : I am attempting a TURNSocket (XEP-0065 - SOCKS5) using the iOS XMPPFramework and an OpenFire Server. I want to be able to send and receive files. However, in most scenarios, the receiver returns no response. I currently suspect the problem…
Andy A
  • 4,191
  • 7
  • 38
  • 56
1
vote
1 answer

Sending Multicast UDP by GCDAsyncUdpSocket fails, no activity in Wireshark

It works okay for any known IP like this: [udpSocket sendData:datatosend toHost:@"192.168.1.113" port:port withTimeout:-1 tag:0]; But when i'm trying to use broadband multicast, nothing logged and nothing goes on [udpSocket sendData:datatosend…
Horhe Garcia
  • 882
  • 1
  • 13
  • 28
1
vote
1 answer

set max packet size for GCDAsyncUdpSocket

I am using the GCDAsyncUdpSocket to send/receive data to a multicast group. In the GCDAsyncUdpSocket.m file, I found the setting bellow and changed the value to 32768 for example. But I can't still receive any packet that is larger than 9216…
user523234
  • 14,323
  • 10
  • 62
  • 102
1
vote
2 answers

iPhone - Peer to Peer connection over the internet

I am building an app that uses a async socket connection with a web server. For sending large amounts of data I would like to connect two iPhones into a Peer to Peer connection using an async socket. I am more familiar with GCDAsyncSocket than to…
Andrei Neacsu
  • 1,453
  • 3
  • 20
  • 33
1
vote
1 answer

How to convert the java bytes to swift int

I use GCDAsyncSocket to achieve the socket in iOS , I receive the package head first use socket.readData(toLength: 5, withTimeout: -1, tag: 0) then I will calculate the body length in didRead delegate and use socket.readData(toLength: bodySize,…
jansma
  • 1,605
  • 1
  • 15
  • 22
1
vote
2 answers

Not getting read data simultaneously GCDAsyncSocket

I have two service class here. One is Host service and another is Join service class. From the HostService I am publishing NetService. In the JoinService I am using NetServiceBrowser for getting published service. Then successfully connected to that…
1
vote
1 answer

iPhone: IPv4 Wi-Fi access fails with cellular radio enabled

I've got an iPhone app that makes UPnP queries over Wi-Fi to locate a Wi-Fi-connected camera, using GCDAsyncSocket. All the communications use IPv4 addresses over an ad-hoc network created by the cameras themselves, and the app is working properly…
Adam Wilt
  • 553
  • 4
  • 10
1
vote
0 answers

How to stop GCDAsyncUdpSocket send command?

I am using GCDAsyncUdpSocket for communication between my app and some smart-home hardware, and I have a problem with stopping a certain function. Logic goes something like this: Send a command If you didn't receive feedback from the hardware,…
vla
  • 11
  • 2
1
vote
1 answer

Get the content length from first two bytes of modified Java UTF (created using java writeUTF() method) in swift

I am using GCDAsyncSocket to create a TCP client on iOS (using swift). The client is communicating with a TCP server written in JAVA. The data is written to to the socket using the JAVA's writeUtf() method. So to read the data on the TCP client, I…
Suraj
  • 33
  • 2
  • 6