Jump to content

OpenPort and communicate via Python (Socket)


Recommended Posts

Hey guys,

I saw there is a hscript command ‘openport’, but I didn't find example on how to communicate with houdini via python.

Here's what I need to do:

1-Open a port, from localHost, within houdini session.
2-From an external python interpreter, execute houdini python commands, using local port.
IE: hou.node('/obj').createNode('geo')

Here's how I can do this in maya:

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(('', 7555))
c = ‘python(“cmds.polySphere()”);’

Does anyone know if it's possible to this in houdini?

Anyone has some examples?


Link to comment
Share on other sites

  • 1 month later...

Exactly the same would be in Houdini:

def houdini_send(msg):
    import socket
    HOST = "localhost"
    PORT = 12100
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((HOST, PORT))
    s.send(msg + '\n')
    res = s.recv(1024)
    return res


But consider using hrpyc instead for general interaction.


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...