<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello, I've been playing around with the new socketed API and I have a few questions. <div><br></div><div>My end goal is to create a simple javascript server. But for now I'm trying to see if I understand how the sockets work.</div><div><br></div><div>In my testing I start an ipython kernel:</div><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; ">$ ipython qtconsole</span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; ">[IPKernelApp] To connect another client to this kernel, use:</span></font></div></div><div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; ">[IPKernelApp] --existing --shell=49785 --iopub=49786 --stdin=49787 --hb=49788</span></font></div></div></blockquote><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; "><br></span></font><div>Then, in another terminal I try to send a command manually to the shell socket (using python):</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; ">import socket</span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; ">import json</span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; "><br></span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; ">shell_sock = socket.create_connection(('localhost',49785))</span></font></div></div><div><div><span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; ">header = { 'msg_id' : 'uuid-123', 'username': 'sean', 'session': '??', 'msg_type': 'connect_request', }</span></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; "><br></span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; ">msg = dict(parent_header=parent_header, header=header, content=content)</span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; "><br></span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; ">msg_str = json.dumps(msg)</span></font></div></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; "><br></span></font></div><div><div><span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; ">shell_sock</span><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; ">.send(msg_str)</span></font></div><div><span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; ">shell_sock</span><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 11px; ">.recv(1024**2)</span></font></div></div><div><br></div></blockquote><br><div>This does not work, and I do not get any response. Why? I would use zmq but the server is implemented in javascript.  I also can not use ajax or jquery from the client-side html notebook app because this is on the server side.</div><div><br></div><div>Thanks in advance.</div><div>~Sean</div><div><br></div></body></html>