Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 852237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:33:41+00:00 2026-05-15T07:33:41+00:00

I’m trying to use LISTSERV’s API in PHP. L-Soft calls this TCPGUI, and essentially,

  • 0

I’m trying to use LISTSERV’s “API” in PHP. L-Soft calls this TCPGUI, and essentially, you can request data like over Telnet. To do this, I’m using PHP’s TCP socket functions.

Here’s the C code provided by L-Soft:

C: http://www.lsoft.com/manuals/16.0/htmlhelp/advanced%20topics/TCPGUI.html#2334328

I’ve provided the PHP conversion I’m using in my first answer. I hope this helps someone someday.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:33:42+00:00Added an answer on May 15, 2026 at 7:33 am

    This is a one command at a time function a colleague wrote. Still wondering if more can be done in terms of flexibility, efficiency, and speed.

    /*
     * lcmd - execute LISTSERV command
     *
     * This function connects to a LISTSERV host and executes a single command
     * using the supplied credentials.
     *
     * Returns result from command if successful; otherwise, returns FALSE.
     */
    function lcmd($host, $port, $user, $password, $cmd) {
        $request_header = "";
        $request_body = "";
        $response_header = "";
        $response_body = "";
        $length = 0;
        $status;
        $result;
    
        /*
     * Get host address
     */
    $host = gethostbyname($host);
    
    /*
     * Connect to server
     */
    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    
    if (!$socket) {
        return FALSE;
    }
    
    $status = socket_connect($socket, $host, $port);
    
    if (!$status) {
        return FALSE;
    }
    
    /*
     * Format request body
     */
    $request_body = "${cmd} PW=${password}";
    
    $length = strlen($user) + strlen($request_body) + 1;
    
    /*
     * Format request header
     */
    $request_header = array();
    
    $request_header[] = "1B\r\n";
    $request_header[] = chr((int)($length / 256));
    $request_header[] = chr($length % 255);
    $request_header[] = chr(strlen($user));
    $request_header[] = $user;
    
    $request_header = implode($request_header);
    
    /*
     * Send request header
     */
    $status = socket_send(
        $socket,
        $request_header,
        strlen($request_header),
        0
    );
    
    if (strlen($request_header) != $status) {
        return FALSE;
    }
    
    /*
     * Receive response header
     */
    while (socket_recv($socket, $b, 1, 0) == 1) {
        $response_header .= $b;
        if ("\n" == $b) {
            break;
        }
    }
    
    $status = (int)$response_header;
    
    /*
     * If status is not 250, then the is refusing the request.
     */
    if (250 != $status) {
        return FALSE;
    }
    
    /*
     * Send request body
     */
    $status = socket_send(
        $socket,
        $request_body,
        strlen($request_body),
        0
    );
    
    if (strlen($request_body) != $status) {
        return FALSE;
    }
    
    /*
     * Receive response body
     *
     * The first 8 bytes of the body is two unsigned 32-bit integers
     * that define the status of the command and the length of the
     * result.
     */
    $status = socket_recv($socket, $response_body, 8, 0);
    
    if (8 != $status) {
        return FALSE;
    }
    
    /*
     * Decode unsigned 32-bit big-endian integer status and result
     * length.
     */
    $response_body = str_split($response_body);
    
    $status = (
        (ord($response_body[0]) << 24 ) |
        (ord($response_body[1]) << 16 ) |
        (ord($response_body[2]) <<  8 ) |
        (ord($response_body[3]) <<  0 )
    );
    
    $length = (
        (ord($response_body[4]) << 24 ) |
        (ord($response_body[5]) << 16 ) |
        (ord($response_body[6]) <<  8 ) |
        (ord($response_body[7]) <<  0 )
    );
    
    /*
     * If status is not 0, then command execution has failed.
     */
    if (0 != $status) {
        return FALSE;
    }
    
    /*
     * Receive result
     */
    $status = socket_recv($socket, $result, $length, MSG_WAITALL);
    
    if ($length != $status) {
        return FALSE;
    }
    
    /*
     * Disconnect from server
     */
    socket_close($socket);
    
    /*
     * Return
     */
    return $result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.