Share this page

# LrJposChannel.getSocket

Returns the client socket that is used for communication with the server.

`public static Socket getSocket()`

## Return values

This function returns the client socket.

## 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 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: