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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:02:51+00:00 2026-06-18T14:02:51+00:00

I’m new to using Python and sockets in general (only started yesterday) so I’ve

  • 0

I’m new to using Python and sockets in general (only started yesterday) so I’ve been having a lot of issues trying to set up a TCP client and server. The issue I’m having is that I want to send a key from the server to the client. I know that the server grabs the key correctly as it prints out the correct key, however it has a 0 appended to it in a new line and when the key is sent to the client the only thing that is displayed is ” b’0′ “.

I’ve made very little progress due to my lack of experience and after searching for hours I still haven’t found a solution to my problem.

Here is the server code:

import os
from socket import * #import the socket library


HOST = '' #We are the host
PORT = 29876
ADDR = (HOST, PORT)
BUFFSIZE = 4096
message = 'Hello, World!'


serv =  socket( AF_INET,SOCK_STREAM)
serv.bind(ADDR,) 
serv.listen(5) 
print ('listening...')


conn,addr = serv.accept()
print (conn,addr)
print ('...connected')


key = os.system("cat ~/.ssh/id_rsa.pub")
conn.send(str(key))
print (key)


conn.close()

Here is the client code

from socket import *
import os

HOST = 'xxx.xxx.xxx.xxx'
PORT = 29876 
ADDR = (HOST,PORT)
BUFFSIZE = 4096
message = "Hello, World!"

cli = socket( AF_INET, SOCK_STREAM)
cli.connect(ADDR,)

data = cli.recv(BUFFSIZE)
print (data)

cli.close()

As you can tell from my code I’m using Python 3.3
Any help with this issue is greatly appreciated.

  • 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-06-18T14:02:52+00:00Added an answer on June 18, 2026 at 2:02 pm

    os.system() does not return the process’s output, but the return value (ie. integer 0).

    If you only want to read a file, do it manually:

    with open(os.path.expanduser("~/.ssh/id_rsa.pub")) as f:
        key = f.read()
        conn.sendall(key)
    

    If you need process output, read the documentation for the subprocess module.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I want use html5's new tag to play a wav file (currently only supported
We're building an app, our first using Rails 3, and we're having to build
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am using JSon response to parse title,date content and thumbnail images and place
I have a jquery bug and I've been looking for hours now, I can't
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.