Android : Want To Block On A Socket For Data?
Jun 25, 2010
What is the efficient way of blocking on the socket for data after opening it.The method i used is to call read on input stream (this is a blocking call that waits till some data written to this socket).
//Socket creation
SocketForCommunication = new Socket();
InetSocketAddress sAddr = new InetSocketAddress("hostName", 8800);
SocketForCommunication.connect(sAddr,10000);
is = new DataInputStream(SocketForCommunication.getInputStream());
os = new DataOutputStream(SocketForCommunication.getOutputStream());
//Waiting on socket using read method for data
while(true)
{
int data = is.read();
if(data == HEADER_START)
{
processPackage(is);}}
Here problem is read can timeout.Is there a way to register a callback that gets called when data available to read on socket.?
View 2 Replies
Jan 9, 2010
I am facing a problem with a stopping thread which is in a synchronized block. I am using TCP socket. The problem is that I am waiting on a DataInputStream object and I want to create a new socket again but it doesn't allow me to do because of the synchronized block.
I have tried with Thread.interrupted(). I cannot avoid the synchronized block. Is there any other way to do the same?
dis = new DataInputStream(ReadWriteData.kkSocket.getInputStream());
int i = -1;
String aval = ""; //new String();
char c = (char)dis.read();
It is getting blocked on dis.read().
What I should do for escaping the dis.read when I want to create a new socket?
View 3 Replies
View Related
Oct 31, 2009
I am facing some problem during reading data from socket If there is some null data in socket stream so the DataInputStream would not read the full data and the so at the receiving end there is exception for parsing data.What is the right way to read the data from socket so there is no loss of data at any time ?
View 3 Replies
View Related
Nov 2, 2010
i am trying to get an android app to send tcp data to a server on my network. The server was written in c#. When i use the code below to transmit data, the server only receives a whole series of.
Socket socket = new Socket(host, port);
PrintWriter pw = new PrintWriter(socket.getOutputStream(), true);
pw.print("test");
socket.close();
View 3 Replies
View Related
Jun 29, 2010
We have a simple client server architecture between our mobile device and our server both written in Java. An extremely simple ServerSocket and Socket implementation. However one problem is that when the client terminates abruptly (without closing the socket properly) the server does not know that it is disconnected. Furthermore, the server can continue to write to this socket without getting any exceptions. Why? According to documentation Java sockets should throw exceptions if you try to write to a socket that is not reachable on the other end!
View 5 Replies
View Related
Nov 12, 2009
Essentially Im trying to get many many java clients connect to a socket on my ColdFusion server (Using the Socket Gateway). However before i even start to code this, Im a little confused about sockets and their performance. First of all, are sockets meant for many(1000+) clients connecting to one socket (say port 2202) on one server? How is the performance if all there waiting for is basically a ping, or something such that when these clients receive this "ping" they can go get some new data.
View 5 Replies
View Related
Jul 15, 2010
I am writing an Android app that should exchange data to a server over Bluetooth, with the server side on a PC running Ubuntu, using the bluez library, in C (or C++).
My Android app fails (IOException) when I try to connect to my server socket on the PC.
Here is essentially what I in the java code (in Android, full eclipse project here: http://dl.dropbox.com/u/2968234/ThinBTClient.zip)
CODE:...........
This throws IOException after a timeout of 10seconds or so.
On the server side (in Ubuntu 8.10), I basically set up a Bluetooth server socket, along the lines described in the example bluez/sdp-register.c
Down below is my C++ program. To compile it do
g++ -I/usr/include/glib-2.0/ -I/usr/lib/glib-2.0/include -o bt_server bt_server.cpp -lbluetooth
I can do the reverse succesfully, i.e. create a server socket in Android and connect from Linux, however this is not what I want to do!
I think either the problem has to do with my config of Ubuntu.
CODE:................
View 1 Replies
View Related
Apr 17, 2014
I want to know if there is an app or any other way to block all incoming calls on my HTC Desire V phone. (Rooted and stock ROM)
My requirement is to block only "Incoming" calls from a list of pre-selected numbers but I would like to allow everything other then incoming calls.
I am using my phone's default way to reject all calls, but any time someone calls they hear a small ring and then operator message saying
"The Number You Have Called Is Busy...", So the caller understands that I am rejecting the call and expects a call back.
If the message after rejecting a call is like "Switch Off" or something else I am fine.
Required "Incoming Call Barring" , because I spoke with my operator regarding incoming calls barring password but I was told that it is phone feature so I needed to contact handset manufacturer for this and I got the same answer from HTC that it is a network feature so I need to contact service provider.
View 4 Replies
View Related
Nov 14, 2009
I have one question thats really been bugging me because I can't seem to find it any where over the internet. My question is, Can i totally block off Data Usage through just the phone itself? Is there any possible solutions? I want this phone, but just to have the wifi capability, I do not want any expensive data charges. If this phone is not possible to do so, I know some are, but I do not know which. How about the Htc Touch Diamond? Or any other phones you guys possibly know of that can disable the data function.
View 10 Replies
View Related
Aug 20, 2010
Canada is incredibly close, and I'm going to be visiting it again in a week but the first time since having a smartphone. I'd like to leave the phone on for voice calls and wifi (I've researched and understand the per-min rates), but I want to guarantee that not 1 byte of data will transfer and incur me some obscene surcharge.
Here's my plan:
- Turn off "data roaming"
- Uncheck "background data"
- Uncheck "auto-sync"
- Using QuickSettings, toggle "APN control" (seems to do the same thing as the APNDroid and Toggle Data apps)
Have I covered all my bases?
View 6 Replies
View Related
May 25, 2010
I am trying to find a way to block incoming calls while I am on the internet. It seems like right when I am about to finally get to what I am looking for someone calls just to say what's up. Is there an app or setting that will send those calls straight to voicemail
View 3 Replies
View Related
Oct 27, 2010
In my android application i am trying to run a application using GPRS connection and not WIFI.When tried to run in wifi the app runs fine.The browser works fine with the APN settings set but when trying to connect to server using my application it gives me socket exception.I am using the below permissions in manifest file.
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses- permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>
<uses-permission android:name= "android.permission.CHANGE_NETWORK_STATE"></uses-permission>
<uses-permission android:name= "android.permission.WRITE_APN_SETTINGS" ></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" ></uses-permission>
I am receiving Socket not connected exception.Is there any other permission which i need to add for using GPRS connection other than WIFI.
10-27 18:26:19.689: WARN/CalSyncSvc(166): com.motorola.blur.service.email.protocol.activesync.ASException: Problem executing HTTP POST
10-27 18:26:19.689: WARN/CalSyncSvc(166): at com.motorola.blur.service.email.protocol.activesync.ActiveSyncMgr.sendRequest(Unknown Source)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at com.motorola.blur.service.email.protocol.activesync.ActiveSyncMgr.sendXMLCommandNoProvisoning(Unknown Source)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at com.motorola.blur.service.email.protocol.activesync.ActiveSyncMgr.sendXMLCommand0(Unknown Source)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at com.motorola.blur.service.email.protocol.activesync.ActiveSyncMgr.sendXMLCommand(Unknown Source)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at com.motorola.blur.service.email.protocol.activesync.ActiveSyncMgr.sendFolderSyncCommand(Unknown Source)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at com.motorola.blur.service.email.protocol.activesync.ProviderAPI.sendFolderSync(Unknown Source)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at com.motorola.blur.service.email.protocol.activesync.ProviderAPI.updateMapFromFolderSync(Unknown Source)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at com.motorola.blur.service.email.protocol.activesync.ProviderAPI.updateFromFolderSync(Unknown Source)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at com.motorola.blur.calendar.sync.activesync.SyncService.syncAccount(Unknown Source)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at com.motorola.blur.calendar.sync.activesync.SyncService$QueueEntry.run(Unknown Source)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:416)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:256)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at java.util.concurrent.FutureTask.run(FutureTask.java:122)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:648)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:673)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at java.lang.Thread.run(Thread.java:1058)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at com.motorola.blur.util.concurrent.BlurThreadFactory$BlurPooledThread.run(Unknown Source)
10-27 18:26:19.689: WARN/CalSyncSvc(166): Caused by: java.net.SocketTimeoutException: Socket is not connected
10-27 18:26:19.689: WARN/CalSyncSvc(166): at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocketImpl(Native Method)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocket(OSNetworkSystem.java:140)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:229)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:521)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at java.net.Socket.connect(Socket.java:1019)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:317)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:129)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
10-27 18:26:19.689: WARN/CalSyncSvc(166): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
10-27 18:26:19.689: WARN/CalSyncSvc(166): ... 17 more
View 2 Replies
View Related
Feb 17, 2010
I am trying to use httpclient to hit a http link. For some reason I keep on geting this "socket is not connected" error. I am not sure about the reason for this error. Can any one help? This error also occurs when I start using the car navigation app or whenever I try to forward calls.
View 5 Replies
View Related
Mar 3, 2009
I have a java server which run on the pc, and a client which run on the G1. Now, G1 is connected to the pc with a usb cable. I want to use socket to let them communicate with each other, as what I did in the emulator. But now G1 cannot find the server through the ip "10.0.2.2".InetAddress serverAddr = InetAddress.getByName ("10.0.2.2"); ClientSocket = new Socket(serverAddr,SERVERPORT); The ClientSocket is null. What's the IP of the pc now?
View 3 Replies
View Related
May 27, 2010
I'm working on application that uses a socket connection.I've implemented 2 different Threads for the read() and the write() methods so they are not being blocked by the read.Everything is working well on the WiFi connection but when I switch to GSM connection the connection becomes unstable without any exception being thrown. It means that there are freezes.the write and read seems to work but no data is actually being piped.
View 10 Replies
View Related
Dec 7, 2009
I wondered if there could be a specific reason why a server socket could refused a client request connection , the server running on one android device the other on the emulator?
View 2 Replies
View Related
Jun 21, 2010
I would like to know what is the recommendation for socket connection management in Android?In our App we would like to be connected to a TCP/IP server when our app is in the foreground or paused. So, create a connection to a TCP/ IP server when the App starts basically, On Create of the launcher activity. However, we do not want to create a new connection and close connection every time an activity is created, paused, destroyed or orientation changed. So, we save the connection object in the App class and the activities will reuse the same connection.Question is when do I close it? I would like to close the socket when the App is "paused", "stopped" or "destroyed". The problem is these messages are not sent in the App context. How can I figure out if the App is in foreground or not? Even the "Terminated" event for an App is not guaranteed to be delivered. So, in that case how do I know when to disconnect?
View 2 Replies
View Related
May 24, 2010
I'm working on application that uses a socket connection. I've implemented 2 different Threads for the read() and the write() methods so they are not being blocked by the read. Everything is working well on the WiFi connection but when I switch to GSM connection the connection becomes unstable without any exception being thrown. It means that there are freezes at the write and read seems to work but no data is actually being piped.
View 2 Replies
View Related
Nov 11, 2010
I'm creating an application that uses an android to send and receive data via bluetooth. but I'm having problems when creating the socket. He gets caught in that line mmSocket btserver.accept = (); And I can not pair with any device.I have another doubt, I can make that communication with an android and a symbian?
View 1 Replies
View Related
Apr 7, 2010
I'm trying to catch socket errors (invalid ip, wrong port, etc.).It seems like the ActivityManager is shutting me down before I have time to catch these errors. I really have no idea what's going on here. My splash screen Haus attempts to start the service from a thread, however when the thread get's to the "about to create socket", it simply locks up. It locks up the entire app until the Force Close dialog box arrives.
I have Log.i all the way into the class that makes the connection.04-07 22:15:29.286: INFO/CONNECTION(19053): 4368 04-07 22:15:29.296: INFO/CONNECTION(19053): establishConnection() 04-07 22:15:29.446: INFO/CONNNECTION(19053): about to create socket 04-07 22:15:34.036: INFO/ActivityManager(76): Displayed activity com.scs.haus/.Haus: 8545 ms (total 8545 ms) 04-07 22:15:38.989: WARN/ActivityManager(76): Launch timeout has expired, giving up wake lock! I never see any of these Logs, except of course for the one that tells me I'm inside the method.
View 2 Replies
View Related
Jul 23, 2010
The documentation for FileDescriptor says it is "The lowest-level representation of a file, device, or socket". I see that some classes like FileOutputStream and LocalSocket expose a getFD(), but Socket doesn't.How do you get at a true (INET) socket's fd? Alternatively, how do you get at the (private) SocketImpl member of Socket named "impl" (this one exposes the fd)
View 4 Replies
View Related
Jun 5, 2009
In the sample code, a SocketTimeoutException should be thrown if the connection can't be stablished in a second, isn't it? But the timeout take a looong time to be detected.
View 4 Replies
View Related
Jun 4, 2010
I'm new to Android development, now I'm working on a simple HTTP server project. I try to use ServerSocket to listen on port 80 but I failed. There will have an exception if I did this. I have already set INTERNET permission in manifest. I found that everything is Okay if I use port 8080, that's strange for me, why I cannot use port 80? I don't want my users to use another port to connect my server.
View 2 Replies
View Related
Jun 25, 2010
I'm now facing a very strange server socket problem, I have a server that will listen on a TCP port, I use the following code to do this work. public class RequestListenerThread extends Thread.
View 4 Replies
View Related
Mar 3, 2010
I have been trying to setup a Droid to Droid 3G connection. I can confirm that all works great in wifi mode. The Droid can make connection requests (Http, Telnet, raw sockets) in 3G, but I cannot get the Droid to accept a socket connection in 3G mode. I was told by Verizon that a special license may be needed to accept socket connection requests and they would send me some information. So far none has been received. If anyone knows how to program the Droid to accept socket connection requests over 3G, please respond. Also if anyone knows why this not allowed please respond.
View 10 Replies
View Related
May 19, 2010
I am attempting to open a ServerSocket on my Android device to receive network connections, but do not seem to recieve network traffic from them. Running netstat -an on the device shows it is listening on 0.0.0.0:1234, but my connections to telnet to <public ip of Android device>:1234 do not appear (and do not receive a SYN,ACK in response). How can I write an application which will open an accessible server socket? Is this possible? I am thinking that either the ISP (mobile carrier) may be blocking this incoming connection attempts or the Android OS is blocking them (host firewall)?
View 4 Replies
View Related
May 5, 2009
I want to send a file from the Android phone to a server by socket.Could anyone give me some example code about how to do it?
View 2 Replies
View Related
Aug 10, 2009
With this SDK version I can use my emulator using a proxy server. There is three solutions: - add values in system table - configure -http-proxy in eclipse run menu - configure APN on emulator to set the proxy. When I use Android browser, it's really slow but it's working. If I try to to a post from my application, I take an ANR and some minutes later a socket time out.
View 2 Replies
View Related
Jan 5, 2010
My chat application connects to a server and information is sent/received by the user. When the connection changes, such as 3g->wifi, wifi->3g, losing a data connection, etc, the socket sometimes stays connected for ages before disconnecting. During this time, it's impossible to tell if the connection is still active, it seems as if messages are being sent just fine. Other times, when sending a message, it will throw an IO error and disconnect.
Apart from implementing code to detect connection changes and reconnecting appropriately, is it possible to have the socket immediately throw an IO exception when connectivity changes?
I'm connecting using the following code:.........
I'm not using setSoTimeout as data may not be transferred for long periods of time depending on the remote server's configuration.
View 2 Replies
View Related
Oct 14, 2010
I tried to connect to a server through a SOCKS server in an Android client app (Android OS 1.5 and 1.6) with below snippet code:
CODE:......
However it gave out an exception on the last line:
CODE:.....................
View 1 Replies
View Related