I don’t think you need the task-handling for the simple read() you’re doing. With a few lines of Python to mimic the server you’re using your original Julia code seems to work fine:
melis@juggle 12:25:~$ cat s.py
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(('', 22401))
s.listen(1)
t,a = s.accept()
r = t.recv(100)
print('got %d bytes: %s' % (len(r), r))
t.sendall('hello!'.encode('utf8'))
melis@juggle 12:25:~$ cat s.jl
# Import Sockets module
using Sockets
# Establish socket connection to the TCP server
tcs = connect(TCPSocket(;delay=false), IPv4("127.0.0.1"), 22401)
# Create 100 byte Char array with command "iraf"
a = Array{Char,1}(undef,100)
a[1:4] = collect("iraf")
# Write the message to the socket
write(tcs,String(a))
# Read message back from the server
r = read(tcs)
println("read '$(r)'")
close(tcs)
# terminal 1
melis@juggle 12:27:~$ python s.py
got 100 bytes: b'iraf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
# terminal 2
melis@juggle 12:27:~$ j s.jl
read 'UInt8[0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x21]'
After all, your Python of the client also used a blocking call to sock.recv(1024) and it worked, so I don’t see why the Julia equivalent would not work similarly.
Edit: one thing that is different in the Julia code is that the read() call doesn’t specify the amount of bytes to read. That might cause a longer wait before it returns. E.g. you can try read(tcs, 40) to read at most 40 bytes.