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 4547514
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:06:10+00:00 2026-05-21T16:06:10+00:00

I am trying to establish a local telnet session in C++ and send commands/receive

  • 0

I am trying to establish a local telnet session in C++ and send commands/receive data. Right now I have:

const char *cmd = "telnet 127.0.0.1 2006";
char buffer[256];

FILE *pipe = popen(cmd, "rw");   
//if( !pipe ) { perror("popen"); exit(-1); }

while( fgets(buffer, sizeof(buffer), pipe) != NULL &&   
      !feof(pipe) )
{
    if( ferror(pipe) ) { perror("fgets"); break; }

    /* Here you do whatever you want with the data. */
    printf("%s", buffer);
}

pclose(pipe);

Which is opening the telnet connection. I need to send a command like: “/neighbors” and then receive the data it would return. Ideally, the session would remain open and I would re-query “/neighbors” every 20 seconds or so.

I think I need to create a child process with fork(), but I am very new to this process.

  • 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-21T16:06:11+00:00Added an answer on May 21, 2026 at 4:06 pm

    Using telnet seems like a rather roundabout way to do this. Have you considered using regular sockets to talk to the remote process? For example, try this guide to socket programming.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to establish and access a session from my servlet, but I can't
Right now I'm trying to connect from a Classic ASP VBScript page to an
In mongo db > show dbs admin (empty) data 23.9423828125GB local (empty) I have
Just trying to establish whether prototype can do something like $$('#ID a:last').css('color','#111'); Any ideas
I'm trying to establish a second database connection to another database on another server.
I'm trying to establish workflows for creating new projects and for setting old projects
I'm trying to establish a relationship between two models in Rails but I am
I am trying to establish upper / lower bound in my stored procedure below
I was trying to establish the licence of the API demos at developer.android.com as
i am trying to establish a connection with access database using java... But while

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.