Closed decadence closed 2 years ago
Since SNMP operates over UDP, it should not be strictly necessary to close it I would think. Are you seeing issues because of it?
I have no issues, just think about it because PHP native library has close method
The SNMP extension functions very differently from this library. I assume the extension uses some wrapper around a C based SNMP library.
I added a close()
method on the SnmpClient class that will close the underlying socket connection. Though I would only use it if you find a need for it. The only circumstances I can see it being useful is if you changed the transport
option of this library to use tcp
instead of udp
. Or if you have a long running PHP process with several SnmpClient classes instantiated that do not go out of scope and thus need to cleanup resources.
Otherwise, with normal usage PHP would end up just cleaning up the socket resource once it goes out of scope. So in a short lived script It wouldn't really be necessary to close the connection, IMO. There is no such message for a "close" in the SNMP protocol.
I tagged a new version that adds the close()
method if you would like to use it. If you have any issues with it let me know!
Thanks! Yes, I am using long running PHP console script with multiple SnmpClient instances. Without issues so far but explicit close
will be helpful anyway. Maybe I'll switch transport to tcp (didn't know about this possibility)
transport option
I don't see it in current documentation 🤔
Found it in source code. Seems to be it can be udp
or tcp
Found it in source code. Seems to be it can be
udp
ortcp
Sorry, I lost track of this since I had marked the issue as closed!
I did not officially document the ability to use the client over TCP as I'm not sure I have it all implemented correctly. I think this is the document that officially describes how SNMP should work over TCP. I'd have to take a closer look at it to "officially" support it.
Hello. Do I need to close
SnmpClient
after usage? For example if I have several instances of this class. I don't see any corresponding method in SnmpClient.php.