Comments (2)
I have a similar situation.
The first byte of data tells me the length of the rest of the packet. Header packets are in my case recognisable by bit 0 = 1, bit 4 = 0, bit 7 = 0. Is there an easy way to do this with (GDC)AsyncSocket?
Is the proper way to do a Read-with-length: 1 until I encounter a header packet and then Read-with-length: bodySize?
from cocoaasyncsocket.
Zyphrax, I found the solution (at least for situations when for every request you receive a response). Yes, you need to call readToLength in onSocket:didWriteDataWithTag: in AsyncSocket delegate method:
- (void)onSocket:(AsyncSocket *)sock didWriteDataWithTag:(long)tag {
...
[sock readDataToLength:<preferred size of response packet> withTimeout:myTimeout tag:tag];
//instead of
//[sock readDataWithTimeout:myTimeout tag:tag];
}
If you don't use terminator then for every request you make (for every write to server) you need to tell AsyncSocket when to callback on read.
However, was not able to deal with subscription type events when handling data coming from a server without a request. Here's my post on stackoverflow http://stackoverflow.com/questions/9517101/is-asyncsocket-suitable-for-subscription-events
I'm closing the issue.
from cocoaasyncsocket.
Related Issues (20)
- Is this still maintained? HOT 1
- Is this library supported for iOS 13+ ? HOT 2
- Error Domain=NSPOSIXErrorDomain Code=60 "Operation timed out" HOT 1
- [!] Error installing CocoaAsyncSocket [!] /usr/bin/git clone https://github.com/robbiehanson/CocoaAsyncSocket.git /var/folders/44/pdz2cl0561z4jh2377tl293h0000gp/T/d20221207-3976-gkz985 --template= --single-branch --depth 1 --branch 7.6.5 HOT 1
- π¦ ALL IN ONEπ
- crashed on iOS 16.1, SIGTRAP HOT 2
- App crash in Xcode 14 and iOS 16 HOT 6
- how to creat a unix domain socket on iOS device HOT 1
- the app references non-public selectors in cocoaAsyncSocket HOT 1
- [GCDAsyncSocket closeWithError:] crash, iOS16 HOT 4
- Not able to build the framework after upgrading Xcode to 14.3 HOT 1
- Not work with bitcode enable HOT 2
- GCDAsyncSocket with local ip address changed HOT 5
- socket gets disconnected with nil error, as soon as didAccept delegate is called HOT 2
- Privacy Manifest HOT 7
- Is there any plan to update TLS API to Network.framework? HOT 2
- crash about (null) in @objc TcpClient.socket(_:didRead:withTag:) () in Xcode HOT 1
- Crash: Thread 8: EXC_BAD_ACCESS (code=1, address=0x555555555555555d) HOT 6
- Increase macOS deployment target HOT 2
- Technically possible to implement getPeerCertificate and getCertificate ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cocoaasyncsocket.