Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Original thread:
Post 8 made on Saturday September 28, 2013 at 18:04
bibi-12
Long Time Member
Joined:
Posts:
February 2008
16
I have un problem with socket.The error is " Maximum active socket count reached" but I close the socket I don't understand why the maximum socket count is reached.

Have I missed something in my code?


var brightness=0;

onRotary = function(clicks)
{

if (socket_bri && socket_bri.connected)
{
try
{ socket_bri.close();
}
catch (e)
{
Diagnostics.log('close error! e: ' + e);
}
finally
{
socket_bri = null;
}
}

if (clicks >= 3)
{
socket_bri=null;
var socket_bri = new TCPSocket(false);
brightness=parseInt(brightness)+5*clicks<=255?parseInt(brightness)+5*clicks:255;
var JSON_commande='{"bri":'+brightness+'}';
socket_bri.connect('192.168.0.158', 80, 3000);

function setBright(commands)
{
socket_bri.write('PUT /api/newdeveloper/groups/all/action HTTP/1.1\r\nContent-Length: '+commands.length+'\r\n\r\n'+commands);

}
socket_bri.onConnect = function()
{
setBright(JSON_commande);

};
socket_bri.onClose = function()
{
socket_bri = null;

}
socket_bri.onIOerror = function()
{
System.print("error");
try {
socket_bri.close()
socket_bri = null
} catch(e) {}



}


}}


Hosting Services by ipHouse