12-01-2010, 08:16 AM
|
#1 (permalink)
|
| New Member
Join Date: Dec 2010 Model: bold PIN: N/A Carrier: att
Posts: 2
Post Thanks: 0 Thanked 0 Times in 0 Posts
| TCP / IP Listener Please Login to Remove! I am trying to create a TCP / IP Listener on an application on the BlackBerry Bold to listen to a specific ip address and port on a pc. From what I've gathered from reading from posts, is that the listener on my handheld will probably be disconnected after 2-3 min of no activity. So I would need to create some sort of "pulse" or "heartbeat" every so often back to the pc. Am I right in this assumption?
Also, The pc is needing some sort of acknowledgement that I'm trying to, or have connected to listen. Below is the code that I use to create the listener. Using this code, will it send or create some sort of data packet that the application on the pc will see or know that I'm trying to listen in on that ip address and port??
while (!_stop) {
try {
String URL = "socket://"+ip+":"+port+";deviceside=true";
_conn = (StreamConnection)Connector.open(URL);
_in = new InputStreamReader(_conn.openInputStream());
while (!_stop) {
StringBuffer sb = new StringBuffer();
int datum = -1;
while ( -1 != (datum = _in.read()) ) {
sb.append((char)datum);
}
notifyListeners((sb.toString()));
}
} catch (IOException e) {
System.err.println(e);
}
}
Thanks in advance for your input. |
| Offline
| |