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

  • Home
  • SEARCH
  • 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 9109263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:00:09+00:00 2026-06-17T03:00:09+00:00

I want to write Python code to send a file from client to server.

  • 0

I want to write Python code to send a file from client to server. server needs to save the file sent from the client. But my code have some bugs which I cannot fix. Below is my server code:

# server.py
from SimpleXMLRPCServer import SimpleXMLRPCServer
import os

server = SimpleXMLRPCServer(('localhost', 9000))

def save_data(data):
    handle = open("x123.dat", "wb")
    handle.write(data)
    handle.close()

server.register_function(save_data, 'save_data')
server.serve_forever()

And the client code:

# client.py
import sys, xmlrpclib

proxy = xmlrpclib.Server('http://localhost:9000')
handle = open(sys.argv[1], "rb")
proxy.save_data(handle.read())
handle.close()

But then I run my code, the client returns the following error (this is on Windows):

Traceback (most recent call last):
File "client.py", line 6, in <module> proxy.save_data(handle.read())
File "c:\python27\lib\xmlrpclib.py", line 1224, in __call__
  return self.__send(self.__name, args)
File "c:\python27\lib\xmlrpclib.py", line 1575, in __request
  verbose=self.__verbose
File "c:\python27\lib\xmlrpclib.py", line 1264, in request
  return self.single_request(host, handler, request_body, verbose)
File "c:\python27\lib\xmlrpclib.py", line 1297, in single_request
  return self.parse_response(response)
File "c:\python27\lib\xmlrpclib.py", line 1473, in parse_response
  return u.close()
File "c:\python27\lib\xmlrpclib.py", line 793, in close
  raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: "<class 'xml.parsers.expat.ExpatError'>:not well-formed (invalid token): line 7, column 1">

I have some questions:

  1. How to fix the above bug?

  2. My code needs to transfer some big files sometimes. Since my method is so simple, I doubt that it is efficient for moving big data. Could anybody please suggest a better method to move big files? (Of course it is better to use XMLRPC on Python)

  • 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-17T03:00:11+00:00Added an answer on June 17, 2026 at 3:00 am

    Server side:

    def server_receive_file(self,arg):
            with open("path/to/save/filename", "wb") as handle:
                handle.write(arg.data)
                return True
    

    Client side:

    with open("path/to/filename", "rb") as handle:
        binary_data = xmlrpclib.Binary(handle.read())
    client.server_receive_file(binary_data)
    

    This worked for me.

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

Sidebar

Related Questions

I want to write some python code in a wordpress blog but whitespaces are
I have started to write a Python 3.x client application. The server application exists
I want to send a csv file from Android to Python AppEngine. I'm using
I need to write a client-server application. I want to write it in python,
I write a lot of Python code where I just want to read a
As part of some WSGI middleware I want to write a python class that
I usually write python in emacs. I'll often want to re-evaluate my file, which
I try to write a daemon in python. But I have no idea how
I want to write a web-based code generator for a Python crawler. Its aim
Considering that I want to write python code that would run on Google App

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.