Solved

socket erroe when invoking python from java app

Posted on 2004-09-09
3
224 Views
Last Modified: 2010-04-16
hi everyone,

I seem to have a winsock error when I tried to invoke my python xml server from within my java application. I know the server works fine because I checked it independently, I also manually started the server and then call the functions from my java app the problem is when I tried to start the python server from within the app I get the following error

Traceback (most recent call last):

  File "C:/Python23/new folder/file.py", line 1307, in ?

    server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8080))

  File "C:\Python23\lib\SimpleXMLRPCServer.py", line 450, in __init__

    SocketServer.TCPServer.__init__(self, addr, requestHandler)

  File "C:\Python23\lib\SocketServer.py", line 329, in __init__

    self.socket_type)

  File "C:\Python23\lib\socket.py", line 154, in __init__

    _sock = _realsocket(family, type, proto)

socket.error: (10091, 'Network subsystem is unvailable')


Any idea on why this happens?

thanks
0
Comment
Question by:jom20
3 Comments
 
LVL 11

Accepted Solution

by:
cjjclifford earned 50 total points
ID: 12024989
Hi,

Its probably related to runtime environments in this case - when you run the python application from cmdline, and it works, have a look at the environment (particularly around Python related paths/variables, and shared library/DLL paths/variables (its likely that the socket library (winsock?) is a DLL that needs some environment set (I don't use windows, so I can't figure it out completely). The environment that the java program is invoked is not passed on in calls to Runtime.exec(), you have to use the Runtime.exec() method that allows setting environment (i.e. the one with 3 arguments).

Try the following:

list the environment from cmdline.
run the python program
if the program works, unset one of the environment variables.
keep trying till one the program fails for the same reason as it is in Java - this is what needs to be set!

Cheers,
C.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Less strange, but still introduction This introduction was added (1st August, 2011) to reflect some reactions.  Firstly, the term basics in the title of the article...  As any other word, it is a symbol with meaning attached to the word by some a…
Here I am using Python IDLE(GUI) to write a simple program and save it, so that we can just execute it in future. Because when we write any program and exit from Python then program that we have written will be lost. So for not losing our program we…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now