Re: [Maya-Python] socket.error: [Errno 10061]

619 views
Skip to first unread message

Nick Burkard

unread,
Oct 13, 2012, 2:34:30 PM10/13/12
to python_in...@googlegroups.com, python_in...@googlegroups.com
Don't use commandPort, use a listener python socket script in your maya or batch session to listen and just exec() the strings your sending.

On Oct 13, 2012, at 10:33 AM, Ali Khanbabaei <ali.k...@gmail.com> wrote:

hi guys.
when i run this script ,i get this error : ocket.error: [Errno 10061] No connection could be made because the target machine actively refused it
what i should to do?

import socket
HOST ="192.168.1.2" #destination IP
PORT =7000
ADDR=(HOST,PORT)
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(ADDR)
MyMessage = 'polyCube()'
client.send(MyMessage)
data = client.recv(1024)
client.close()
print 'The Result is %s'%data

///////////////////////////////
explain:
-os : 7
-pyVer :2.6
-mayaVer:2013
-firewall in client and server is off
-run commandPort -n ":7000" in client

--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe

Justin Israel

unread,
Oct 13, 2012, 3:24:57 PM10/13/12
to python_in...@googlegroups.com
===
commandPort: http://download.autodesk.com/global/docs/maya2012/en_us/CommandsPython/index.html

name(n)
Specifies the name of the command port which this command creates.
CommandPort names of the form name create a UNIX domain socket on the
localhost corresponding to name. If name does not begin with "/", then
/tmp/name is used. If name begins with "/", name denotes the full path
to the socket. Names of the form :port number create an INET domain on
the local host at the given port
===

It only opens a local port, so you must access it via "localhost" or
"127.0.0.1". It is not exporting to the ip 192.168.1.2

Ali Khanbabaei

unread,
Oct 13, 2012, 3:58:51 PM10/13/12
to python_in...@googlegroups.com
Thank you(Nick Burkard and Justin Israel)  for your answers.
I think it worked before correctly, but I do not know why it gives error now(Maybe I'm wrong)
if maybe please explain a little more because i am not Professional. 
Finally, what should I do?
(Sorry if my English is not good)

Justin Israel

unread,
Oct 13, 2012, 4:09:37 PM10/13/12
to python_in...@googlegroups.com
Are you sure that exact code worked before? I could swear you need to
access it on a local ip address:

HOST ="127.0.0.1"

Ali Khanbabaei

unread,
Oct 13, 2012, 4:28:19 PM10/13/12
to python_in...@googlegroups.com
no i am not sure.but i just think it happened.
i want write a simple chat program in maya and i need connect from network.how i can send message to client?

Justin Israel

unread,
Oct 13, 2012, 4:37:51 PM10/13/12
to python_in...@googlegroups.com
If you are writing a chat program, take Nick's advice and create your
own socket in a thread from within Maya. The Maya commandPort is only
really useful for directly calling the API, and from the local
machine. You probably want to have a custom listener socket open on
the network IP.

Justin Israel

unread,
Oct 13, 2012, 4:40:33 PM10/13/12
to python_in...@googlegroups.com
Open your command port on a network IP:

cmds.commandPort(n="192.168.1.2:7000")

Justin Israel

unread,
Oct 13, 2012, 4:43:20 PM10/13/12
to python_in...@googlegroups.com
I sent that last mail too soon. Forgot the disclaimer:

It is a bad idea to open a command port on the network interface (or
any public one), because anybody can connect to it and have Maya do
arbitrary system commands without any authentication. This is the
reason it is by default a local port.

At least with your own python socket, you can handle the incoming data
and do exactly and only what you want. The commandPort is just a port
to any Maya command you want.

Ali Khanbabaei

unread,
Oct 13, 2012, 5:00:49 PM10/13/12
to python_in...@googlegroups.com
Thank you so much
i understand my wrong.
i should run this script (cmds.commandPort(n="192.168.1.2:7000") ) in client while i run  (cmds.commandPort(n=":7000") or  (cmds.commandPort(n="127.0.01:7000").
before that i say it happened i run  (cmds.commandPort(n="192.168.1.2:7000")

Ali Khanbabaei

unread,
Oct 13, 2012, 5:11:34 PM10/13/12
to python_in...@googlegroups.com
yes. i know that it is dangerous.
but it is not a Commercial script and i just want to practice
Reply all
Reply to author
Forward
0 new messages