<div dir="ltr">yah i did the search, and tried the solution, but it didn&#39;t work.... nice of you to have tried, though...<div><br></div><div>anyhow, i found where the problem is... on the client side it should be connect() instead of bind() in :</div>
<div><br></div><div>&gt; tcpCliSock.bind(ADDR) </div><div><br></div><div>thanks <br><br><div class="gmail_quote">On Fri, Apr 6, 2012 at 4:59 PM, Evert Rol <span dir="ltr">&lt;<a href="mailto:evert.rol@gmail.com">evert.rol@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">&gt; i&#39;m trying to implement a server that adds a time stamp to incoming text form a client.<br>

&gt;<br>
&gt; the server&#39;s code is (but doesn&#39;t seem to have the problem as demoed by the error below:<br>
&gt;<br>
&gt; from socket import *<br>
&gt; from time import ctime<br>
&gt;<br>
&gt; HOST = &#39;&#39;<br>
&gt; PORT = 21567<br>
&gt; BUFSIZ = 1024<br>
&gt; ADDR =(HOST, PORT)<br>
&gt;<br>
&gt; tcpSerSock = socket(AF_INET, SOCK_STREAM)<br>
&gt;<br>
&gt; tcpSerSock.bind(ADDR)<br>
&gt; tcpSerSock.listen(5)<br>
&gt;<br>
&gt; while True:<br>
&gt;     print(&#39;waiting for connection ...&#39;)<br>
&gt;     tcpCliSock, addr =tcpSerSock.accept()<br>
&gt;     print(&#39;...connected from: &#39;, addr)<br>
&gt;<br>
&gt;     while True:<br>
&gt;         data = tcpCliSock.recv(BUFSIZ)<br>
&gt;         if not data:<br>
&gt;             break<br>
&gt;         tcpCliSock.send(&#39;[{}] {}&#39;.format(bytes(ctime(), &#39;utf-8&#39;),data))<br>
&gt;<br>
&gt;     tcpCliSock.close()<br>
&gt; tcpSerSock.close()<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; the client&#39;s code is:<br>
&gt;<br>
&gt; from socket import *<br>
&gt;<br>
&gt;<br>
&gt; HOST = &#39;localhost&#39;<br>
&gt; PORT = 21567<br>
&gt; BUFSIZ = 1024<br>
&gt; ADDR =(HOST, PORT)<br>
&gt;<br>
&gt; tcpCliSock = socket(AF_INET, SOCK_STREAM)<br>
&gt;<br>
&gt; tcpCliSock.bind(ADDR)<br>
&gt;<br>
&gt; while True:<br>
&gt;     data=input(&#39;&gt; &#39;)<br>
&gt;     if not data:<br>
&gt;         break<br>
&gt;     tcpCliSock.send(data)<br>
&gt;     data = tcpCliSock.recv(BUFSIZ)<br>
&gt;     if not data:<br>
&gt;         break<br>
&gt;     print(data.decode(&#39;utf-8&#39;))<br>
&gt;<br>
&gt; tcpCliSock.close()<br>
&gt;<br>
&gt; the problem is i get the following error when i enter some text:<br>
&gt;<br>
&gt; Traceback (most recent call last):<br>
&gt;   File &quot;C:\Python32\tsTclnt3.py&quot;, line 17, in &lt;module&gt;<br>
&gt;     tcpCliSock.send(data)<br>
&gt; TypeError: &#39;str&#39; does not support the buffer interface<br>
<br>
</div></div>Did you try to search on the error string? That would have gotten you the solution (even) faster.<br>
The first two Google hits (and probably all the rest of them), tell me that Python 3&#39;s socket.send() method wants bytes as input, not str. See <a href="http://docs.python.org/py3k/library/socket.html#socket.socket.send" target="_blank">http://docs.python.org/py3k/library/socket.html#socket.socket.send</a><br>

<br>
Hope that helps,<br>
<br>
  Evert<br>
<br>
<br>
&gt;<br>
&gt; can you help?<br>
&gt; _______________________________________________<br>
&gt; Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
&gt; To unsubscribe or change subscription options:<br>
&gt; <a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br>
</blockquote></div><br></div></div>