[Spread-users] port limitation to int16

Johannes Wienke jwienke at techfak.uni-bielefeld.de
Thu Aug 8 09:41:48 EDT 2013


On 07.08.13 16:04 schrieb John Schultz:
> I see it.  It looks like that limitation was removed with 4.3.0.
> I think you can safely remove that check from your version or upgrade to 4.3.

I just tried this with version 4.3 with mixed results. If I use e.g.
48000 at localhost in the SP_connect call, the connection succeeds.
However, if I try to use a local socket by providing only the port
number connection does not work. Attached is a test program which
demonstrates this problem.

The connection problems in the case of socket communication are actually
caused by the daemon itself. Looking at the output at start I can see:

Conf_load_conf_file: My name: localhost, id:, port: -17536
Membership id is ( 2130706433, 1375968222)
Configuration at localhost is:
Num Segments 1
	1       -17536

Notice the negative port numbers. There is an integer overflow in the
daemon and this does not only exist in the printing. Actually the socket
file in /tmp is really called -17536. The client API doesn't seem to
have this overflow and tries to correctly find a file with name 48000.

Strangely, the TCP listen port is constructed without this overflow and
the daemon correctly listens on 48000:

languitar at miles:~$ lsof -i tcp:48000
spread  72864 languitar    6u  IPv4 0x665a353ce83db745      0t0  TCP
*:nimcontroller (LISTEN)

Kind regards,
-------------- next part --------------
#include <sp.h>
#include <iostream>

using namespace std;

int main() {

    cout << "SPREAD_VERSION: " << (SPREAD_VERSION >> 24) << "." << ((SPREAD_VERSION >> 16) & 0xFF) << "." << (SPREAD_VERSION & 0xFF) << endl;

    mailbox con;
    char spreadPrivateGroup[MAX_GROUP_NAME];
    int code = SP_connect("48000", 0, 0, 0, &con, spreadPrivateGroup);
    cout << "connect only port return code: " << code << endl;
    code = SP_connect("48000 at localhost", 0, 0, 0, &con, spreadPrivateGroup);
    cout << "connect host and port return code: " << code << endl;
    return 0;    

-------------- next part --------------
Spread_Segment {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.spread.org/pipermail/spread-users/attachments/20130808/ab8e0701/attachment.bin 

More information about the Spread-users mailing list