tcp_new requires a node address, _listen method doesn't want it #32

Closed
karlp opened this Issue Oct 14, 2011 · 3 comments

Comments

Projects
None yet
2 participants
@karlp
Contributor

karlp commented Oct 14, 2011

In modbus_new_tcp_pi(), (I haven't looked at the regular version), the following code is used to set up the hostname of the remote server: https://github.com/stephane/libmodbus/blob/master/src/modbus-tcp.c#L701

ret_size = strlcpy(ctx_tcp_pi->node, node, dest_size);

Then in modbus_tcp_pi_listen there is a check no the node element being 0, which then properly sets up the socket to listen on NULL, for any address. https://github.com/stephane/libmodbus/blob/master/src/modbus-tcp.c#L435

However, given the way the check is done in new(), there's no way to set the node to a zero value. I suggest that if the incoming node is NULL, that it be set to zero,

@karlp

This comment has been minimized.

Show comment
Hide comment
@karlp

karlp Oct 14, 2011

Contributor

Ok, this only is a problem for the pi contexts. I just switched to regular tcp for the master, and it works just fine now. For tcp, it ignores the ip address if you use the listen/accept pairs

Contributor

karlp commented Oct 14, 2011

Ok, this only is a problem for the pi contexts. I just switched to regular tcp for the master, and it works just fine now. For tcp, it ignores the ip address if you use the listen/accept pairs

@stephane stephane closed this in 8f1cc7b Jan 15, 2014

@stephane

This comment has been minimized.

Show comment
Hide comment
@stephane

stephane Jan 16, 2014

Owner

Hi Karl,

Never too late ;)
Thanks for the report.

Owner

stephane commented Jan 16, 2014

Hi Karl,

Never too late ;)
Thanks for the report.

mk8 added a commit to mk8/libmodbus that referenced this issue Jan 29, 2014

Allow to listen any hosts in IPv6 (closes #32)
- allow an empty string or NULL for node argument
- protect against NULL in service argument
- new test for NULL service
- update documentation
@karlp

This comment has been minimized.

Show comment
Hide comment
@karlp

karlp Apr 15, 2014

Contributor

Thanks for this, and thanks for #190 as well, making the regular tcp_ method also observe the addresses passed in :)

Contributor

karlp commented Apr 15, 2014

Thanks for this, and thanks for #190 as well, making the regular tcp_ method also observe the addresses passed in :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment