thanks jean-Pul.i can use commandline to intercat with server by the StandardIO.<br>it&#39;s so easy with it <br><br>and there is a sample in Twisted NetWork Programming Essentials<br><br>wow<br><br>from twisted.internet import stdio, reactor, protocol&nbsp;
<br>from twisted.protocols import basic&nbsp;
<br>import re&nbsp;
<br>&nbsp;
<br>class DataForwardingProtocol(protocol.Protocol):&nbsp;
<br>&nbsp;&nbsp;&nbsp; def _ _init_ _(self):&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.output = None&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.normalizeNewlines = False&nbsp;
<br>&nbsp;
<br>&nbsp;&nbsp;&nbsp; def dataReceived(self, data):&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if self.normalizeNewlines:&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; data = re.sub(r&quot;(\r\n|\n)&quot;, &quot;\r\n&quot;, data)&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if self.output:&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.output.write(data)&nbsp;
<br>&nbsp;
<br>class StdioProxyProtocol(DataForwardingProtocol):&nbsp;
<br>&nbsp;&nbsp;&nbsp; def connectionMade(self):&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inputForwarder = DataForwardingProtocol( )&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inputForwarder.output = self.transport&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inputForwarder.normalizeNewlines = True&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stdioWrapper = stdio.StandardIO(inputForwarder)&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.output = stdioWrapper&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Connected to server.&nbsp; Press ctrl-C to close connection.&quot;&nbsp;
<br>&nbsp;
<br>class StdioProxyFactory(protocol.ClientFactory):&nbsp;
<br>&nbsp;&nbsp;&nbsp; protocol = StdioProxyProtocol&nbsp;
<br>&nbsp;
<br>&nbsp;&nbsp;&nbsp; def clientConnectionLost(self, transport, reason):&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reactor.stop( )&nbsp;
<br>&nbsp;
<br>&nbsp;&nbsp;&nbsp; def clientConnectionFailed(self, transport, reason):&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print reason.getErrorMessage( )&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reactor.stop( )&nbsp;
<br>&nbsp;
<br>if __name__ == &#39;_ _main_ _&#39;:&nbsp;
<br>&nbsp;&nbsp;&nbsp; import sys&nbsp;
<br>&nbsp;&nbsp;&nbsp; if not len(sys.argv) == 3:&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Usage: %s host port&quot; % _ _file_ _&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sys.exit(1)&nbsp;
<br>&nbsp;
<br>&nbsp;&nbsp;&nbsp; reactor.connectTCP(sys.argv[1], int(sys.argv[2]), StdioProxyFactory( ))&nbsp;
<br>&nbsp;&nbsp;&nbsp; reactor.run( )&nbsp;
<br><br><br><br><br><div class="gmail_quote">On Tue, Dec 2, 2008 at 10:11 PM, Jean-Paul Calderone <span dir="ltr">&lt;<a href="mailto:exarkun@divmod.com">exarkun@divmod.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">On Tue, 2 Dec 2008 21:38:18 +0800, lei ren &lt;<a href="mailto:reynold.lei@gmail.com" target="_blank">reynold.lei@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
hello ,everybody:<br>
 &nbsp;i am a new to use the twisted. i woul&#39;d like to complete a WEBGAME with<br>
it.but i have a problem for the twisted<br>
i have complete the server ,and the simple client.but ,i want to the client<br>
have more function. one is let the usr input some command to the server<br>
but when i write the code ,i found it&#39;s hard ,if i want to get the user&#39;s<br>
input with raw_input() in a while loop,but it will block to wait the user&#39;<br>
input<br>
what can i do for this .use thread? of twisted have some more power feature<br>
for the problem,,thank you every body<br>
<br>
ps:the problem like a MUD game ,user can send the command to the server and<br>
reveive the message from server .and the user can send command everytime<br>
<br>
</blockquote>
<br></div></div>
The way to read from stdin without blocking the reactor is to use<br>
twisted.internet.stdio.StandardIO, a transport which lets a protocol<br>
interact with standard in and standard out.<br><font color="#888888">
<br>
Jean-Paul</font><div><div></div><div class="Wj3C7c"><br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com" target="_blank">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</div></div></blockquote></div><br>