[TIMOB-8014] iOS: Ti.Network.Socket.TCP "timeout" property's unit is seconds and not milli-second
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-04-19T17:51:57.000+0000 |
Affected Version/s | Release 1.8.0.1 |
Fix Version/s | Release 2.0.0, Sprint 2012-06 |
Components | iOS |
Labels | module_network, qe-testadded |
Reporter | Akira Suzuki |
Assignee | Stephen Tramer |
Created | 2012-02-28T03:16:29.000+0000 |
Updated | 2012-04-19T17:51:57.000+0000 |
Description
When the following app run on Android, it outputs ">>Socket error:Unable to connect, IO error" in TextArea after the 10 seconds since the button pressed.
On the other hand, on iPhone, it output nothing after 10 seconds.
And it output ">>Socket error:Attempt to connect to host timed out" after 10 seconds, by replacing "timeout: 10000" to "timeout: 10".
It seems the unit of timeout property in iOS is second, besides the API Doc explicitly describe "in milliseconds".
var win = Ti.UI.createWindow({
backgroundColor: "#eee",
layout: "vertical"
});
var textarea = Ti.UI.createTextArea({
value: "",
left: 0,
top: 0,
width: 320,
height: 200
});
var button = Ti.UI.createButton({
title: "Connect",
top: 20,
height: 50,
width: 100
});
win.add(textarea);
win.add(button);
var buffer = Ti.createBuffer();
var socket = Ti.Network.Socket.createTCP({
host: "192.168.100.200",
port: 50000,
timeout: 10000,
connected: function(e) {
textarea.value += ">>Connected\n";
socket.read(buffer);
textarea.value += buffer + "\n";
},
error: function(e) {
textarea.value += ">>Socket error:" + e.error + "\n";
}
});
button.addEventListener('click', function(e) {
socket.connect();
});
win.open();
I assume that the host "192.168.100.200" does NOT exist. If some server is listening on 192.168.100.200:50000, it works as I desire.
Akira's pull request for this issue is here: https://github.com/appcelerator/titanium_mobile/pull/1427
Tested on iPhone 3gs 4.3.5 with 2.0.0.v20120319003254
Reopening to update labels.