steveohara / j2mod

Enhanced Modbus library implemented in the Java programming language
Apache License 2.0
267 stars 111 forks source link

Retrieve the localPort from opened socket if port is set to 0 #19

Closed chepseskaf closed 8 years ago

chepseskaf commented 8 years ago

It's possible to set the listening port to 0 in order to bound the first available port, but it's not possible to retriev this port. I think it would be usefull to provides a getter on this port.

steveohara commented 8 years ago

It isn't possible to set the listening port to 0. If you attempt to do that, the listener will default to 502. I assume this is what you mean?

steveohara commented 8 years ago

I've added getPort() and getAddress() to AbstractModbusListener https://oss.sonatype.org/content/repositories/snapshots/com/ghgande/j2mod/2.1-SNAPSHOT/j2mod-2.1-20160531.121216-2.jar