Hello, I was testing sockets in tcl and I got a tcl server and tcl client to communicate correctly.
I thought I would try using a python client to send data to my tcl server.
The python client will send data but the tcl server will output it as a empty string when I get it from the channel.
I was wondering if this was the tcl servers fault or the python clients fault?
Thanks.
server:
proc accept {chan addr port} {
fconfigure $chan -blocking 0 -buffering line
fileevent $chan readable [list receive $chan]
puts "$addr joined"
}
proc receive {channel} {
puts [chan gets $channel]
close $channel
}
socket -server accept 5000
vwait forever
client:
import socket
def client_program():
host = "
shaun.rubenportier.be" # as both code is running on same pc
port = 5000 # socket server port number
client_socket = socket.socket() # instantiate
client_socket.connect((host, port)) # connect to the server
message = input(" -> ") # take input
client_socket.send(message.encode()) # send message
client_socket.close() # close the connection
if __name__ == '__main__':
client_program()