I need to connection with socket host but to Android device.
If I send data infinitely then only android host get data. Otherwise, it is not able to get it.
Actually, I am developing an iOS app which need to communicate to Android app.
Android app :
it will create wifi hotspot and socket server. our android developer has also create android client app which can send & receive message (Byte) to/from server.
iOS app :
it will just connect to socket server. For this, I need to go to Wifi setting and manually connect to wifi hotspot created by Android server app. I read your article, It is very helpful to make connection to server. I can successfully connect to socket server. But Android server app only able to read stream if I pass long data or small data infinitely. I had asked question at here
No. I just send string “I am here”. Now, I send string as “I am here \n”. It call - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode;
I am using the same code and increases the buffer size from 1024 to 50012 but it is not able to read whole 50012 bytes at a time.We are transferring a 26MB Image from linux server to IPAD and data is divided in to buffer of 50012 bytes but when we use this method after increasing the buffer size most of the bytes are getting missed so we are getting distorted image.Can you please suggest which approach i should follow.
i have tried that method but i am able to read only 2000 bytes at a time .Can u please tell how can we read 50012 bytes in one read .
Below is the source code for reference .
NSInteger result;
uint8_t buffer[50012]; // BUFFER_LEN can be any positive integer
while((result = [inputStream read:buffer maxLength:50012]) != 0) {
if(result > 0) {
NSLog(@“result…%ld”,(long)result);
[self OCRImageSave:buffer];
// buffer contains result bytes of data to be handled
} else {
// The stream had an error. You can get an NSError object using [iStream streamError]
}
}
I am trying to implement an iOS chat application using websockets.
The question is how does message delivery work when the iOS app is in the background. Is the message lost because the socket connection is broken when the app is in the background?
If yes, then do I have to implement a state refresh protocol every time the app comes to foreground?
When the connection is down the message won’t be sent.
Yes, you need a way to cache messages somewhere and send them when the app is online again.
Background mode is “ice on the cake”. Many chat apps use it to refresh the list of messages so that when the user opens the app there’s no need to wait for the UI to refresh. But background mode should NOT be used as the means to cache messages.
excellent tutorial, thanks for this.
I want to ask you some thing, I need open a socket for send a string between two apps on the same ipad.
This applied too?
Client and Server on the same iPad, and the server could be in background state.
PD: Sorry by my english, but I am from Chile and my english is not the best.