<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 2, 2011, at 12:15 AM, Kurt Spindler wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div><div>&nbsp;Second question is that, in that other bunch of code, I need to be able to write things to the socket. How can I access the instance of my protocol subclass that is used by the factory, so I can make protocolInstance.transport.write type calls? Or am I thinking about this is a completely wrong way?</div><div><br></div></div></span></blockquote><br></div><div><br></div><div><div>This may be my favorite FAQ answer:&nbsp;</div><div><a href="http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions%23HowdoImakeinputononeconnectionresultinoutputonanother">http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#HowdoImakeinputononeconnectionresultinoutputonanother</a></div><div><br></div><div>You're not specifically asking that question, but the salient point is:</div><div><br></div><div>"These are just regular Python objects; you can put them into lists, dictionaries, or whatever other data structure is appropriate to your application"</div><div><br></div><div>You can access connected protocol instances using something like the pattern in that FAQ. Just keep a reference to the factory instance somewhere in your other code and access whatever data structure you choose to store the protocol references.&nbsp;MultiEchoFactory has a list of connected protocols ('echoers'). You could just keep one connected instance. Or a dictionary keyed by ip address, session id you generate, etc.</div><div><br></div><div>One other note... how you end up integrating with whatever GUI you are using may impact your use of Twisted APIs (i.e. transport.write).</div><div>See</div><div><a href="http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#WhydoesittakealongtimefordataIsendwithtransport.writetoarriveattheothersideoftheconnection">http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#WhydoesittakealongtimefordataIsendwithtransport.writetoarriveattheothersideoftheconnection</a></div><div>(gotta love that anchor!...&nbsp;<a href="http://bit.ly/gPvW7d">http://bit.ly/gPvW7d</a>)</div></div><br></body></html>