Server Sockets in java - java

I am creating an app for android which uses server socket over wifi-connectivity to exchange data between devices. I am able to send and receive data from server (hotspot) device.
My problem is that I want to send data to all other client devices as soon as it is received on server device from a client. Any IDEA how implement it??
Also the data I am exchanging is an Audio stream. Any suggestions will be appreciated..!!

Related

How can I send and receive data to a fingerprint device using Java

How can I send and receive data to a fingerprint device using java ,
I am working on a desktop application using java that controls the fingerprint device and I need at some point to send and receive data from and to the fingerprint device.
My question is how to connect the device to the desktop application and how to send and receive data.
Thank you in advance

Use XMPP to implement a push notification infrastructure

I am currently working on a project which requires a server to request data from the devices which are currently connected to the server. Meaning, first the server finds out which devices are connected to the server and then sends an application specific message to the client device which should wake certain functionality present on the client.
I was looking into XMPP service which looked promising since it works as a PUSH notification. The in XMPP can be used to check if the device is currently connected and has subscribed to the server. Since every android user has a gmail account, I was thinking of using the gmail xmpp service to connect /subscribe to the server. Then send specific message to the client, i.e x...#gmail.com.
However if a message is sent this way the client app gets the message as well as the native gtalk client. So how do I go about intercepting this so that it doesn't show up on the gtalk client but my app still gets it ?
Use the full JID when sending the message. The send to multiple clients should only occur when the bare JID is used.
Full JID -> xyz#gmail.com/device
Bare JID -> xyz#gmail.com

How can I send a notification?

I am developing an Android App that communicates with a server.
How can I send a notification from my server to my Android App without the use of C2DM?
Are Sockets a good solution? What are other alternatives?
I'd suggest you to develop a webservice preferably with JSON which is easy to handle. This server client architecture will hellp you to send and receive any kind of data (ranges from raw text to images or even video)
Check out C# webservices. That are very easy to start than the PHP services IMHO.
Depends on what you want to do.
have you thought on how does the server identifies the client to send the message ? In this case the android phone ?
With http you would need the client to "request" this notification.
The closest thing to an actual notification would be to have a socket connection, which the client would connect to the server. But then would require an existent connection between the two. If this is ok for what you are doing, then go ahead if you really want to avoid C2DM.
But, using C2DM allows your server to send notification to devices without a need for a request or direct connection from the client. The only thing you need to do is pass the identification of the device to your third-party server given when you authenticate with google's C2DM. After that, you just push notification data to C2DM and google delivers the notification for you.
I've used MQTT for providing push notifications on Android and it's proved to be a good, reliable, low power solution.
Some links to support my case / get you started:
http://mqtt.org/
Power Profiling: MQTT on Android
Basic Steps for Using MQTT in android

wireless connection between mobile device and pc

I would like to establish a connection between a mobile device and computer so they can interact with each other. I should be able to send and receive data at both the ends, just like a chat client. How do I go about it? I just want to know the steps involved. I was thinking about sending the data from the device to a database server and then accessing it through the PC, and doing the same on the mobile device, too. Is this a good idea? What alternatives are there?
Since you're using android, this is pretty easy. One easy option is to code a client and server application for your android device and pc. Or, you could just send data on the UDP connectionless protocol.
I'm assuming you know how to build apps for an android phone. There is no need of an intermediate node (a database server or the like), if the goal here is as small as just sending data back and forth.
Here's a good example of a UDP server/client implementation.
And here's a good one for TCP server/client.
Hope that helps.

How does a Bluetooth Socket connection work on Android?

I am new to bluetooth. I understand on Android I can connect to another bluetooth device as a client through a BluetoothSocket connection. How do I handle data that is received? In what format does data get sent from the server to the client?
Going through your questions:
How do I handle data that is received?
The ideal way to handle data is with threads (although it is possible to use a service). A single connected thread running through an infinite loop will attempt to try to read data from the stream that is provided by the socket connection.
In what format does data get sent from the server to the client?
Data is sent from server to client via bytes (specifically arrays of bytes). If you know the type of data being received, there are plenty of functions to convert this data to the desired variable type.
For a complete example of how bluetooth works between devices, I'd highly recommend taking a look at the source of the BluetoothChat Sample application. There's also the Bluetooth overview.

Categories