Share this page

# LrJposChannel.setLocalAddress

Sets the local host and port for the channel. It is used if the process fails to get the local address.

`public static void setLocalAddress (String iface, int port)`

## Parameters

Parameter | Description
--- | ---
iface | The address of the local host.
port | The port used for the connection.

## Return values

This function does not return any values.

## Example

Copy code

    public void simpleISOtest_localIFace() throws Throwable{

            GenericPackager packager = new GenericPackager(PACKAGERCONFIGFILE);
            LrJposChannel.initChannel(LrJposChannel.ChannelType.ASCIIChannel, "localhost", 8000, packager);

            //setting the localhost and port using "setLocalAddress()" API
            LrJposChannel.setLocalAddress("localhost", 8001);

            LrJposChannel.connect();

            LrISOMsg m = new LrISOMsg();
            m.setMTI("0100");
            m.set(ISO87Fields.PAN_PRIMARY_ACCOUNT_NUMBER, "1234567890000000000");
            m.set(3, "523456");
            m.set(4, "123456789121");
            m.set(12, "20241605108110");
            m.set(47, "32432");

            LrJposChannel.send(m);

            LrISOMsg r = LrJposChannel.receive();
            if (r!=null) {
                lr.output_message(r.getMTI());
            }

            Socket socket = LrJposChannel.getSocket();
            if (socket == null) {
                lr.error_message("socket cannot be null");
            }
            LrJposChannel.disconnect();
            LrJposChannel.closeChannel();
    }

Tips to improve your search results... VuGen Function Reference Version 25.1-25.3 Function Reference 25.1-25.3 All View Local Help Center View Online Help Center Version: