I am a newbiee in socket communication....android client,
I am facing a problem to communicate my android client to C# server using TCP protocol only so that i can when my server queries some data or information to the android client, the client responds back. communication will be over Wi-fi.
plz guide.
Any help is appreciated...
Thanx
Android Developers
has plenty of docs on how Android does that -- there is no shortage of stuff ready
Related
I am writing a mobile trading app (android/ios) and i need suggestions on the best way to connect the app to the server (messageQ)
If i use raw TCP connection , would my users have a problem if they are behind corporate wifi's (protected by firewalls)? If yes, in that case, is web socket a better solution?
With the backend server, after researching with zeroMq, i believe a full fledged broker like rabbitmq is a better option to start with. Now , if i use a web socket connection from my native app, Rabbit MQ has a sockJS-AMQP bridge . But i am not sure, if there is a java and iOS web socket client to speak to sockJS server .
Any experienced views is greatly appreciated
Have you considerer to use MQTT?
If you don't need AMQP you can also use directly an MQTT broker, such as http://mosquitto.org/ or http://www.hivemq.com/
Here (https://github.com/owntracks) you can find some ready libraries for iPhone and Android.
In order to solve the the firewall problem MQTT is available over HTTP.
You can read here:
http://www.hivemq.com/mqtt-over-websockets-with-hivemq/
or
here http://mqtt.org/wiki/doku.php/mqtt_over_websockets
This post can also help you : (https://www.ibm.com/developerworks/community/blogs/sowhatfordevs/entry/using_mqtt_protocol_advantages_over_http_in_mobile_application_development5?lang=en)
For a iPhone application I used directly MQTT and as server RabbitMQ with the MQTT plug-in
http://www.rabbitmq.com/mqtt.html
I hope it can be usefulĀ
I am trying to build a server/web service which provides APIs to Android/iOS client. I am using WCF service and clients can send request to server successfully. Now, I am going to make server enable to ping client to notify that there some changes in server and client need to synchronize data.
The question is: Is it possible to enable my server to ping client (Android/iOS), I knew that it is possible for Windows client by using wsDualHttpBinding but I am not sure about iOS and Android client. Anyone can help me to make it clear? Any solution is appreciated.
I don't think you can do it. For start, while wsDualHttpBinding is intended to be interoperable I don't beleive in practice it is supported by any otehr framework than WCF. Then wsDualHttpBinding uses a client callback url that the server needs to contact. This url is not going to be accessible on a phone. You should use websockets, long polling or some proprietary push mechanism of the device os.
what is the best way to create a two way constant communication between a server and an android app?
When I say constant communication, I mean client asking server for data or server constantly pushing data to clients.
From what I saw, I can't use websockets since they are designer for server/browser setups. Is that right? If so, what is the alternative?
Is there free frameworks to work with this in Android?
What I am trying to do is an application that works like a chatting but for multiple people. So they all will get in one "room or channel" on their devices, and then interact with each other, in a way handdled by the server.
Thanks!
As far as I know , one possible way is using a web service where the client can connect to the server , if the web service is RESTFul there are many libraries to access it , one of them is the apache HTTPClient , for the server pushing the only way I know is C2DM for pushing data to clients.
For continuously-open data connection, you may use Sockets. But you should also consider the fact that an always-open connection will drain your battery quickly too. For more details, read this and this
You may want to look at AutobahnAndroid:
https://github.com/tavendo/AutobahnAndroid
which provides native Android/Java WebSocket client framework (plus WAMP = PubSub/RPC over WebSocket .. http://wamp.ws).
This is fully interoperable with WebSocket servers that server browser clients.
The AutobahnXX libraries (where XX = Python, JS, Android) are Open-Source (Apache 2.0). We (Tavendo) are offering a commercial virtual appliance based on Autobahn: http://autobahn.ws
Disclaimer: I am author of Autobahn and work for Tavendo.
But keeping the connection running on the background on iOS and Android devices does drain the battery, for people who have this issue, I suggest using push notifications when the app is not on the foreground.
From what I saw, I can't use websockets since they are designer for
server/browser setups. Is that right? If so, what is the alternative?
Websocket is an IETF/W3C protocol, so it is not confined to a specific client platform. You can use Android websocket to get a two-way communication between Android and server side. For Android websocket client, I recommend using AndroidAsync. It has all websocket API that you need to establish the communication link and exchange data between Android and the server.
I am looking to leverage my existing (and quite simple) NodeJS+SocketIO server application with a new Android based client. This is not using the WebKit browser, but a native WebSocket client within the Android SDK.
I have found the library "Weberknecht" and loaded it into my Android project, and when I attempt a connection to the WebSocket URL I see a "WARN - client not handshaken client should reconnect" message in my NodeJS trace.
Presumably the SocketIO framework does some extra work pre-WebSocket and that is why I am having issues. Has anyone else done this kind of "cross-library" work against SocketIO, and if so could you offer any assistance please.
There is already a Java client for Socket.IO, you can look at the different port at the wiki page. Also, there is a description of the socket.IO protocol on the wiki page.
It seems like the first thing that Java port does when it connects is that it sends a "1::(path)" connect message. Are you sending the connect message?
If you are still looking for an answer, then checkout out https://github.com/koush/android-websockets, which got released recently. It has full support for socket.io server running in node.js
I am having a task,considering one emulator as server and i have to access a web service from the client emulator.I think this is not possible in android,if anyone knows about it please send some code snippets to do this.
Android's java.net package is pretty much the same as Java's so you can use Sockets and ServerSockets for TCP communication or a DatagramSocket for UDP.
However, there is currently no support for SOAP webservices in the android SDK but you can use third party libraries or build your own. Have a look at the following questions:
How to call a net web service from android
Regarding connecting to a webserver from android