Anytime Help Center

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Support
  • Guest
  • Log In
English (US)
US English (US)
DE German
CN Chinese
MX Spanish (Mexico)
Chinese (Simplified)
  • AKG
    Microphones Wireless Integrated Systems Automatic Mixers Headphones Discontinued Products (AKG) General AKG Inquiries Certifications (AKG)
  • AMX
    Networked A/V Distribution (AVoIP) Traditional A/V Distribution Video Signal Processing Architectural Connectivity User Interfaces Control Processing Power (AMX) Programming (AMX) Software (AMX) Discontinued Products (AMX) General AMX Inquiries Certifications (AMX)
  • BSS
    Soundweb™ Omni Soundweb™ London Soundweb™ Contrio™ Software (BSS) Discontinued Products (BSS) General BSS Inquiries Certifications (BSS)
  • Crown
    CDi DriveCore Series CDi Series Commercial Series ComTech Series DCi DriveCore Series I-Tech HD Series XLC series XLi Series XLS DriveCore 2 Series XTi 2 Series Discontinued Products (Crown) Software (Crown) General Crown Inquiries Certifications (Crown)
  • dbx
    CX Series 500 Series DriveRack Personal Monitor Control ZonePRO Zone Controllers FeedBack Suppression Microphone Preamps Dynamics Processors Crossovers Equalizers Software (dbx) Discontinued Products (dbx) General dbx Inquiries Certifications (dbx)
  • Flux::
    Immersive Processing Analysis Subscriptions
  • JBL
    Cinema Sound Installed Live Portable Tour Sound Recording & Broadcast Software (JBL) Discontinued Products (JBL) Video Manual Series (JBL) General JBL Inquiries Certifications (JBL)
  • Lexicon
    Plugins Effects Processors Cinema Discontinued Products (Lexicon) Video Manual Series (Lexicon) General Lexicon Inquiries Certifications (Lexicon)
  • Martin
    Atomic ELP ERA Exterior MAC P3 VC VDO Tools Discontinued Products (Martin) General Martin Inquiries Certifications (Martin)
  • Soundcraft
    Digital Analog Connected Analog Only Discontinued Products (Soundcraft) Video Manual Series (Soundcraft) General Soundcraft Inquiries Certifications (Soundcraft)
  • General HARMAN Inquiries
    Dante
+ More
  • Home
  • AMX
  • Programming (AMX)
  • Programming

Telnet Example Application Note

Frequently Asked Questions

Written by Will Fraser

Updated at February 4th, 2026

Table of Contents

Brand: Models: Overview:   Code Example:

Brand:

  • AMX

Models:

  • Netlinx

Overview:  

This example shows the basic concepts of IP Communications.  Specifically, the example creates an IP Client socket and connect to the NetLinx master using the Telnet protocol.  The example issues a "GET IP" command which retrieves all the IP settings from the NetLinx master.  Most of these settings are available using the library call GET_IP_ADDRESS function so this is not the easiest (or recommended!) way to retrieve the IP settings.

Note that most Telnet servers (i.e.  device that accept telnet command) do require the use of the Telnet escape codes.  It is possible that a Telnet server will not establish a connection until the Telnet negotiation sequence has been entered.  How do you know if this is the problem you might be seeing? Telnet escape codes begin with the character 0xFF ($FF, 255 or HEX FF).  If a device sends you this character and will not respond to any of the command you are sending, it probably requires the Telnet negotiation sequence.  Most devices we have encountered so far do not require this: in our experience, the negotiation sequence is not required for the NetLinx master, Polycom codecs, All Windows Telnet servers or most Unix/Linux Telnet servers.  See this link for more information on the Telnet protocol.

Did you notice the IP address used in this example? You might wonder what 127.0.0.1 is.  This is the loopback address.  IP implementations understand this to be the local machine.  In fact, the request you send never makes it out across ethernet.  The IP software simply "short-circuits" the request back to itself without sending it across the wire.  The name "localhost" and "127.0.0.1" are synonymous.


Code Example:

(***********************************************************)

(* DEVICE NUMBER DEFINITIONS GO BELOW *)

(***********************************************************)

DEFINE_DEVICE

(*** NetLinx ***)

dvTELNET = 0:5:0

(***********************************************************)

(* CONSTANT DEFINITIONS GO BELOW *)

(***********************************************************)

DEFINE_CONSTANT

(* IP *)

IP_TCP = 1

IP_UDP = 2

nTELNET_PORT = 23

(***********************************************************)

(* TYPE DEFINITIONS GO BELOW *)

(***********************************************************)

DEFINE_TYPE

(***********************************************************)

(* VARIABLE DEFINITIONS GO BELOW *)

(***********************************************************)

DEFINE_VARIABLE

(* INFO *)

CHAR strTELNET_BUFFER[1000]

SLONG slRESULT

(***********************************************************)

(* SUBROUTINE DEFINITIONS GO BELOW *)

(***********************************************************)

(**************************************)

(* CALL NAME: GET_TELNET_PARAMETER *)

(* FUNCTION: GET PARAMETER FROM STR *)

(* PARAMS: BUFFER - IN *)

(* RETURN: PARAMETER *)

(**************************************)

DEFINE_FUNCTION CHAR[100] GET_TELNET_PARAMETER (CHAR strDATA[])

STACK_VAR

CHAR chCHAR

CHAR strPARAM[100]

{

  (* CLEAN UP AND SHORT CIRCUIT *)

  strPARAM = ""

  IF (LENGTH_STRING(strDATA) = 0)

  RETURN strPARAM;

  (* KILL SPACES *)

  WHILE (strDATA[1] = $20 && LENGTH_STRING(strDATA))

  chCHAR = GET_BUFFER_CHAR(strDATA)

  (* GET UP UNTIL CR *)

  WHILE (strDATA[1] <> $0D && LENGTH_STRING(strPARAM) < 100)

  strPARAM = "strPARAM,GET_BUFFER_CHAR(strDATA)"

  (* DONE *)

  RETURN strPARAM;

}

(***********************************************************)

(* STARTUP CODE GOES BELOW *)

(***********************************************************)

DEFINE_START

(* BUFFERS *)

CREATE_BUFFER dvTELNET,strTELNET_BUFFER

(***********************************************************)

(* EVENT PROCESSING ROUTINES BELOW *)

(***********************************************************)

DEFINE_EVENT

(***************************)

(*** TELNET MESSAGES *******)

(***************************)

DATA_EVENT[dvTELNET]

{

  ONERROR:

  {

    SEND_STRING 0,"'TELNET EVENT: ERROR(',ITOA(DATA.NUMBER)"

    strTELNET_BUFFER = ""

  }

  ONLINE:

  {

    SEND_STRING 0,'TELNET EVENT: ONLINE'

    strTELNET_BUFFER = ""

  }

  OFFLINE:

  {

    SEND_STRING 0,'TELNET EVENT: OFFLINE'

    strTELNET_BUFFER = ""

  }

  STRING:

  {

    (* VARS *)

    STACK_VAR

    CHAR strTEMP[100]

    LONG lPOS

    (* DEBUG *)

    SEND_STRING 0,'TELNET EVENT: INFO'

    (* TELNET MESSAGE? *)

    IF (FIND_STRING(strTELNET_BUFFER,'Welcome',1))

    {

      strTEMP = REMOVE_STRING(strTELNET_BUFFER,'Welcome',1)

      strTELNET_BUFFER = ""

      SEND_STRING dvTELNET,"'GET IP',13,10"

    }

    (* GET IP? *)

    IF (FIND_STRING(strTELNET_BUFFER,'MAC Address',1) && FIND_STRING(strTELNET_BUFFER,'>',1))

    { 

      strTEMP = REMOVE_STRING(strTELNET_BUFFER,'IP Settings',1)

      strTEMP = REMOVE_STRING(strTELNET_BUFFER,"$0D,$0A",1)

      strTEMP = REMOVE_STRING(strTELNET_BUFFER,'HostName',1)

      strTEMP = GET_TELNET_PARAMETER(strTELNET_BUFFER)

      SEND_STRING 0,"'HOST NAME=',strTEMP"

      strTEMP = REMOVE_STRING(strTELNET_BUFFER,'Type',1)

      strTEMP = GET_TELNET_PARAMETER(strTELNET_BUFFER)

      SEND_STRING 0,"'IP TYPE=',strTEMP"

      strTEMP = REMOVE_STRING(strTELNET_BUFFER,'IP Address',1)

      strTEMP = GET_TELNET_PARAMETER(strTELNET_BUFFER)

      SEND_STRING 0,"'IP ADDRESS=',strTEMP"

      strTEMP = REMOVE_STRING(strTELNET_BUFFER,'Subnet Mask',1)

      strTEMP = GET_TELNET_PARAMETER(strTELNET_BUFFER)

      SEND_STRING 0,"'SUBNET MASK=',strTEMP"

      strTEMP = REMOVE_STRING(strTELNET_BUFFER,'Gateway IP',1)

      strTEMP = GET_TELNET_PARAMETER(strTELNET_BUFFER)

      SEND_STRING 0,"'GATEWAY IP ADDRESS=',strTEMP"

      strTEMP = REMOVE_STRING(strTELNET_BUFFER,'MAC Address',1)

      strTEMP = GET_TELNET_PARAMETER(strTELNET_BUFFER)

      SEND_STRING 0,"'MAC ADDRESS=',strTEMP"

      strTELNET_BUFFER = ""

      IP_CLIENT_CLOSE (dvTELNET.PORT)

    }

  }

}

(***********************************************************)

(* THE ACTUAL PROGRAM GOES BELOW *)

(***********************************************************)

DEFINE_PROGRAM

WAIT 200

{

  slRESULT = IP_CLIENT_OPEN (dvTELNET.PORT,'127.0.0.1',nTELNET_PORT,IP_TCP)

  IF (slRESULT < 0)

  SEND_STRING 0,"'IP_CLIENT_OPEN ERROR: ',ITOA(slRESULT)"

}

(***********************************************************)

(* END OF PROGRAM *)

(* DO NOT PUT ANY CODE BELOW THIS COMMENT *)

(***********************************************************)

Related Videos

questions guide

Was this article helpful?

Yes
No
Give feedback about this article

Table of Contents

Brand: Models: Overview:   Code Example:

Related Articles

  • System Call FIRST parameter
  • CISCO SG500-48 Switch Configurations

Related Articles

  • System Call FIRST parameter
  • CISCO SG500-48 Switch Configurations
Copyright © HARMAN Professional. All rights reserved. Privacy Policy | Terms of Use
Expand