DTMgetPortAddr(3DTM)

NAME
DTMgetPortAddr, DTMgetRemotePortAddr - Return the IP address of DTM port(s).

SYNOPSIS
#include <dtm.h>

int DTMgetPortAddr(int portid, char *address, int size)

int DTMgetRemotePortAddr(int portid, char ***addresses, int *num_addresses)

DESCRIPTION
DTMgetPortAddr returns the IP address of DTM port specified by the integer portid. Address is a user-allocated buffer of size size in which the IP address will be stored in the form '000.000.000.000:port', where the "000"'s are the IP numbers of the current host. This is typically used in conjunction with DTMmakeInPort to retrieve the input TCP port number and report it to connecting programs. This is a cause for some confusion. If you do a DTMgetPortAddr on a portid that is an output port, (one created by a call to DTMmakeOutPort), you do not get the IP address of the remote port you are connected to! Rather, you get the IP address of the machine in which the process is executing, followed by the output port number. This is because with version 2.0 of the DTM library, it is possible to be connected to multiple ports at once. For example, if this is the setup where port 8000 (portid 1) is sending to three other DTM ports:

                                      +---> 1.1.1.1:8001
                                      |
     1.1.1.1:8000 (portid: 1)---------+---> 1.1.1.1:8002
                                      |
                                      +---> 1.1.1.1:8003

Then the call to DTMgetPortAddr with the portid of "1" would place the value "1.1.1.1:8000" in the address field. To get the list of ports an output port is sending to, use DTMgetRemotePortAddr.

DTMgetRemotePortAddr creates a list of all ports that are listening on the output port specified by portid. Num_addresses reports the number of ports contained in the list of addresses. The memory for this address list is allocated by DTM and must be freed by the user when no longer needed. For example, if this is the setup where port 8000 (portid 1) is sending to three other DTM ports:

                                      +---> 1.1.1.1:8001
                                      |
     1.1.1.1:8000 (portid: 1)---------+---> 1.1.1.1:8002
                                      |
                                      +---> 1.1.1.1:8003

Then the call to DTMgetRemotePortAddr with the portid of "1" would create a list of addresses containing "1.1.1.1:8001", "1.1.1.1:8002", and "1.1.1.1:8003", with num_addresses would be set to 3.

SEE ALSO
DTM, DTMmakeInPort, DTMmakeOutPort

DIAGNOSTICS
If DTMgetPortAddr encounters an error, it returns the value DTMERROR and sets the DTMerrno variable to be one of the following values:
	DTMHOST	That hostname is not found/bad.
	DTMBUFOVR	User buffer overflow.

DTMgetRemotePortAddr also returns the value DTMERROR should an
error condition arise, and the values that DTMerrno are set to are:
	DTMMEM	Out of memory.
If successful, both of these commands return the value DTM_OK
(DTMNOERROR).

BUGS
DTMgetRemotePortAddr currently only works for port ids that have been created using DTMmakeOutPort. This may change in a future release.