making a chat client and wont work
<p>what's wrong here I'm stuck :(
I'm using <strong>3.4.4</strong> if that helps
I've tried everything! I've even searched on this! It keeps saying:</p>

<pre><code>Traceback (most recent call last):
  File "C:\Users\matthew\Desktop\chatclient.py", line 36, in &lt;module&gt;
    s.sendto(alias.encode() + ": " + message.encode(), server)
TypeError: can't concat bytes to str
</code></pre>

<p>Here's the code:</p>

<pre><code>import socket
import _thread
import threading
import time

tLock = threading.Lock()
shutdown = False

def recieving(name, sock):
    while not shutdown:
        try:
                tLock.acquire()
                while True:
                    data.addr = sock.recvfrom(1024).decode() 
                    print (str(data)) 
        except:
            pass
        finally:
            tLock.release()
host = '127.0.0.1'
port = 0

server = ('127.0.0.1', 5000)

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((host, port))
s.setblocking(0)

rT = threading.Thread(target=recieving, args=("recvthread", s))
rT.start()

alias = input("Name: ")
message = input(alias + "-&gt; ")
while message != 'q':
    if message != '':
        s.sendto(alias.encode() + ": " + message.encode(), server)   
    tLock.acquire()
    message = input(alias + "-&gt; ")
    tLock.release()
    time.sleep(0.2)

shutdown = True
rT.join()
s.close()
</code></pre>

<p>could it be my server I will type it if needed!
and thx again!</p>

<p>The message is right! Once you encode <code>alias</code> and <code>message</code>, they are <code>bytes</code> not strings. But <code>": "</code> is a string, hence the error. In python 3.x, strings are unicode and need to be encoded to bytes to be saved to disk or sent on the wire.</p>

<p>An additional but subtle error is that you are using the default encoding for your computer but really the sending and receiving computers should agree on an encoding and use that. UTF-8 is a good choice.</p>

<p>So, change</p>

<pre><code>s.sendto(alias.encode() + ": " + message.encode(), server)
</code></pre>

<p>to</p>

<pre><code>s.sendto("{}: {}".format(alias, message).encode('utf-8'), server)
</code></pre>

python sockets