Post 2 made on Monday October 10, 2022 at 19:38 |
Lyndel McGee RC Moderator |
Joined: Posts: | August 2001 12,999 |
|
|
You should consider using try/catch around each of those statements and logging any errors with System.print() that you find.
Not sure why you are using System.delay(50) especially since you are not receiving any data. You are effectively halting the entire pronto for 50ms when you do this.
If, for example, your LanSending function throws an error, you could 'leak' a socket if you don't execute SocketLan.close().
Now, note that there are a max of 32 sockets allowed on the Pronto. See Dev Guide A.13.3.1. TCPSocket.setSocketLimit().
I'd do the following within your function (You will need to reformat the tabs/indentation below:
function LanSending(TargetIP,TargetPort,CommandString) { System.setDebugMask(9); var SocketLan; try { SocketLan = new TCPSocket(true); SocketLan.connect(TargetIP, TargetPort, 3000); SocketLan.write(CommandString); } catch(err) { System.print(err.substring(0,90)); Diagnostics.log(err.substring(0,90)); } if (SocketLan) { try {SocketLan.close();} catch(err){ System.print(err.substring(0,90)); Diagnostics.log(err.substring(0,90)); } SocketLan = null; }
|
|
Lyndel McGee Philips Pronto Addict/Beta Tester
|
|