Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

21 May, 2024: Computers section is temporarily disabled for maintenance. It will take several days before it's back.


devel / comp.lang.tcl / Re: Tcl server receiving empty string from python client

SubjectAuthor
* Tcl server receiving empty string from python clientShaun Kulesa
+* Re: Tcl server receiving empty string from python clientsaitology9
|`* Re: Tcl server receiving empty string from python clientShaun Kulesa
| `* Re: Tcl server receiving empty string from python clientsaitology9
|  `* Re: Tcl server receiving empty string from python clientShaun Kulesa
|   +- Re: Tcl server receiving empty string from python clientsaitology9
|   `- Re: Tcl server receiving empty string from python clientRich
`* Re: Tcl server receiving empty string from python clientChristian Gollwitzer
 `* Re: Tcl server receiving empty string from python clientShaun Kulesa
  `* Re: Tcl server receiving empty string from python clientRich
   `- Re: Tcl server receiving empty string from python clientShaun Kulesa

1
Tcl server receiving empty string from python client

<488eaffc-cb9d-4021-a81c-586610af2699n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21694&group=comp.lang.tcl#21694

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:7f2:b0:56e:ff38:46a2 with SMTP id bp18-20020a05621407f200b0056eff3846a2mr2511996qvb.10.1681148063846;
Mon, 10 Apr 2023 10:34:23 -0700 (PDT)
X-Received: by 2002:a05:622a:189a:b0:3e0:dee4:c925 with SMTP id
v26-20020a05622a189a00b003e0dee4c925mr4147735qtc.5.1681148063559; Mon, 10 Apr
2023 10:34:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 10 Apr 2023 10:34:23 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=87.115.149.231; posting-account=Be2r4goAAACg4Ko_BkJ0V-RlkGAdXGng
NNTP-Posting-Host: 87.115.149.231
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <488eaffc-cb9d-4021-a81c-586610af2699n@googlegroups.com>
Subject: Tcl server receiving empty string from python client
From: shaunkulesa@gmail.com (Shaun Kulesa)
Injection-Date: Mon, 10 Apr 2023 17:34:23 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Shaun Kulesa - Mon, 10 Apr 2023 17:34 UTC

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()

Re: Tcl server receiving empty string from python client

<u11o91$29nj8$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21695&group=comp.lang.tcl#21695

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: saitology9@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: Tcl server receiving empty string from python client
Date: Mon, 10 Apr 2023 15:32:48 -0400
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <u11o91$29nj8$1@dont-email.me>
References: <488eaffc-cb9d-4021-a81c-586610af2699n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Apr 2023 19:32:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="925788bae2d3e6869f2047bd1b49904f";
logging-data="2416232"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xNAIEwS0xlGXTh7zbIijb"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:g3v8vCc/9nsCJ2XSpaTBMCwIQOw=
Content-Language: en-US
In-Reply-To: <488eaffc-cb9d-4021-a81c-586610af2699n@googlegroups.com>
 by: saitology9 - Mon, 10 Apr 2023 19:32 UTC

On 4/10/2023 1:34 PM, Shaun Kulesa wrote:
> 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?
>

Not user fault then :-)

Add a newline character yo your messages when sending them from Python,
within this line or as a new subsequent message, and see if it improves
things:

> client_socket.send(message.encode()) # send message

Re: Tcl server receiving empty string from python client

<388917dc-9b5b-4203-aa64-e35e2372b4c1n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21696&group=comp.lang.tcl#21696

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:4593:b0:74a:598b:9241 with SMTP id bp19-20020a05620a459300b0074a598b9241mr3050657qkb.10.1681155986166;
Mon, 10 Apr 2023 12:46:26 -0700 (PDT)
X-Received: by 2002:a05:622a:199e:b0:3e4:db08:ae9c with SMTP id
u30-20020a05622a199e00b003e4db08ae9cmr2868580qtc.8.1681155985941; Mon, 10 Apr
2023 12:46:25 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 10 Apr 2023 12:46:25 -0700 (PDT)
In-Reply-To: <u11o91$29nj8$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=87.115.149.231; posting-account=Be2r4goAAACg4Ko_BkJ0V-RlkGAdXGng
NNTP-Posting-Host: 87.115.149.231
References: <488eaffc-cb9d-4021-a81c-586610af2699n@googlegroups.com> <u11o91$29nj8$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <388917dc-9b5b-4203-aa64-e35e2372b4c1n@googlegroups.com>
Subject: Re: Tcl server receiving empty string from python client
From: shaunkulesa@gmail.com (Shaun Kulesa)
Injection-Date: Mon, 10 Apr 2023 19:46:26 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1419
 by: Shaun Kulesa - Mon, 10 Apr 2023 19:46 UTC

I've tried a mix of combinations using the new line character but the output is still an empty string.

message = input(" -> ") # take input
client_socket.send("\n".encode())
client_socket.send(("\n" + message).encode())
client_socket.send("\n".encode())

Re: Tcl server receiving empty string from python client

<u11p7g$29tl6$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21697&group=comp.lang.tcl#21697

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: saitology9@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: Tcl server receiving empty string from python client
Date: Mon, 10 Apr 2023 15:49:03 -0400
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <u11p7g$29tl6$1@dont-email.me>
References: <488eaffc-cb9d-4021-a81c-586610af2699n@googlegroups.com>
<u11o91$29nj8$1@dont-email.me>
<388917dc-9b5b-4203-aa64-e35e2372b4c1n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Apr 2023 19:49:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="925788bae2d3e6869f2047bd1b49904f";
logging-data="2422438"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ZMMuYbdpagp2YuvZOMXYa"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:HT+BaLQr1Ia0Zs4gKp2QICr8Nf8=
Content-Language: en-US
In-Reply-To: <388917dc-9b5b-4203-aa64-e35e2372b4c1n@googlegroups.com>
 by: saitology9 - Mon, 10 Apr 2023 19:49 UTC

On 4/10/2023 3:46 PM, Shaun Kulesa wrote:
> I've tried a mix of combinations using the new line character but the output is still an empty string.
>
> message = input(" -> ") # take input
> client_socket.send("\n".encode())
> client_socket.send(("\n" + message).encode())
> client_socket.send("\n".encode())

Interesting... I think newlines should not be encoded - they will cease
to become newlines.

Re: Tcl server receiving empty string from python client

<3575addb-2169-471a-8ff0-ef3d158fb901n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21698&group=comp.lang.tcl#21698

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:410e:b0:746:7fbd:e22f with SMTP id j14-20020a05620a410e00b007467fbde22fmr2806712qko.12.1681156632837;
Mon, 10 Apr 2023 12:57:12 -0700 (PDT)
X-Received: by 2002:ac8:7f02:0:b0:3d8:2cb6:d21d with SMTP id
f2-20020ac87f02000000b003d82cb6d21dmr65512qtk.6.1681156632633; Mon, 10 Apr
2023 12:57:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 10 Apr 2023 12:57:12 -0700 (PDT)
In-Reply-To: <u11p7g$29tl6$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=87.115.149.231; posting-account=Be2r4goAAACg4Ko_BkJ0V-RlkGAdXGng
NNTP-Posting-Host: 87.115.149.231
References: <488eaffc-cb9d-4021-a81c-586610af2699n@googlegroups.com>
<u11o91$29nj8$1@dont-email.me> <388917dc-9b5b-4203-aa64-e35e2372b4c1n@googlegroups.com>
<u11p7g$29tl6$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3575addb-2169-471a-8ff0-ef3d158fb901n@googlegroups.com>
Subject: Re: Tcl server receiving empty string from python client
From: shaunkulesa@gmail.com (Shaun Kulesa)
Injection-Date: Mon, 10 Apr 2023 19:57:12 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1691
 by: Shaun Kulesa - Mon, 10 Apr 2023 19:57 UTC

Unfortunately the argument has to be in bytes.

I changed the tcl server receive function to do 3 outputs to match the inputs given by the python client but none of them had the input message from the client as they were all empty strings.

proc receive {channel} {
puts [chan gets $channel]
flush $channel
puts [chan gets $channel]
flush $channel
puts [chan gets $channel]
flush $channel

close $channel
}

Re: Tcl server receiving empty string from python client

<u11q45$29tl5$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21699&group=comp.lang.tcl#21699

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: saitology9@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: Tcl server receiving empty string from python client
Date: Mon, 10 Apr 2023 16:04:21 -0400
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <u11q45$29tl5$1@dont-email.me>
References: <488eaffc-cb9d-4021-a81c-586610af2699n@googlegroups.com>
<u11o91$29nj8$1@dont-email.me>
<388917dc-9b5b-4203-aa64-e35e2372b4c1n@googlegroups.com>
<u11p7g$29tl6$1@dont-email.me>
<3575addb-2169-471a-8ff0-ef3d158fb901n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Apr 2023 20:04:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="925788bae2d3e6869f2047bd1b49904f";
logging-data="2422437"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0CTZpJKAfuuAp8JlE42/J"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:1Rk+wnpD+OFX0AEFRQLpBtX1H+4=
In-Reply-To: <3575addb-2169-471a-8ff0-ef3d158fb901n@googlegroups.com>
Content-Language: en-US
 by: saitology9 - Mon, 10 Apr 2023 20:04 UTC

On 4/10/2023 3:57 PM, Shaun Kulesa wrote:
> Unfortunately the argument has to be in bytes.
>
> I changed the tcl server receive function to do 3 outputs to match the inputs given by the python client but none of them had the input message from the client as they were all empty strings.
>

Try removing the buffering from this line on the tcl side:

> fconfigure $chan -blocking 0 -buffering line

to this:

fconfigure $chan -blocking 0

Re: Tcl server receiving empty string from python client

<u11q7s$2a0p2$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21700&group=comp.lang.tcl#21700

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: auriocus@gmx.de (Christian Gollwitzer)
Newsgroups: comp.lang.tcl
Subject: Re: Tcl server receiving empty string from python client
Date: Mon, 10 Apr 2023 22:06:20 +0200
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <u11q7s$2a0p2$1@dont-email.me>
References: <488eaffc-cb9d-4021-a81c-586610af2699n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Apr 2023 20:06:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="53f3b7b6a57b0442a47d5a3983bdc0f0";
logging-data="2425634"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18k74d1zfPW3670EBnFqR/l1+pAMlpKUtk="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.9.1
Cancel-Lock: sha1:CU2CZ5PCD5ttasgLTdHo+S/Ea5A=
In-Reply-To: <488eaffc-cb9d-4021-a81c-586610af2699n@googlegroups.com>
 by: Christian Gollwitzer - Mon, 10 Apr 2023 20:06 UTC

Am 10.04.23 um 19:34 schrieb Shaun Kulesa:

> 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
> }

I don't know how well non-blocking I/O and gets work together. It may
well be that the first read receives nothing and the second read would
deliber the data. Try changing the receiver like this:

proc receive {channel} {
puts "Got: [read $channel]"
}

Does it change anything? The server won't stop then after 1 line,
obviously, but maybe it spits out an empty string and then the
transmitted data.

Christian

Re: Tcl server receiving empty string from python client

<701a09a4-7d07-43b3-adc9-04837a9f363bn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21701&group=comp.lang.tcl#21701

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:2406:b0:74a:580:c44f with SMTP id d6-20020a05620a240600b0074a0580c44fmr2657285qkn.15.1681159050409;
Mon, 10 Apr 2023 13:37:30 -0700 (PDT)
X-Received: by 2002:a05:620a:1a1a:b0:743:577d:d756 with SMTP id
bk26-20020a05620a1a1a00b00743577dd756mr2673103qkb.4.1681159050095; Mon, 10
Apr 2023 13:37:30 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 10 Apr 2023 13:37:29 -0700 (PDT)
In-Reply-To: <u11q7s$2a0p2$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=87.115.149.231; posting-account=Be2r4goAAACg4Ko_BkJ0V-RlkGAdXGng
NNTP-Posting-Host: 87.115.149.231
References: <488eaffc-cb9d-4021-a81c-586610af2699n@googlegroups.com> <u11q7s$2a0p2$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <701a09a4-7d07-43b3-adc9-04837a9f363bn@googlegroups.com>
Subject: Re: Tcl server receiving empty string from python client
From: shaunkulesa@gmail.com (Shaun Kulesa)
Injection-Date: Mon, 10 Apr 2023 20:37:30 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2055
 by: Shaun Kulesa - Mon, 10 Apr 2023 20:37 UTC

Thanks Christian Gollwitzer, I tested that with two inputs on one connection and it receives both of them. I'm trying to close the connection after the client disconnects as it creates an infinite loop of printing "Got: ".

I got it to work as it closes the socket connection but the receive function continues to run causing an error as the channel no longer exists.

python input:

-> hello
-> hello again

tcl output:

87.115.149.231 joined
Got: hello
Got: hello again
Got:
Client has disconnected.
can not find channel named "sock5573b3ce5050"
while executing
"read $channel"
(procedure "receive" line 8)
invoked from within
"receive sock5573b3ce5050"

receive function:

proc receive {channel} {
if {[eof $channel]} {
close $channel
puts "Client has disconnected."
}

puts "Got: [read $channel]"
flush $channel
}

Re: Tcl server receiving empty string from python client

<u11so7$2abl2$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21702&group=comp.lang.tcl#21702

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Tcl server receiving empty string from python client
Date: Mon, 10 Apr 2023 20:49:11 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <u11so7$2abl2$1@dont-email.me>
References: <488eaffc-cb9d-4021-a81c-586610af2699n@googlegroups.com> <u11o91$29nj8$1@dont-email.me> <388917dc-9b5b-4203-aa64-e35e2372b4c1n@googlegroups.com> <u11p7g$29tl6$1@dont-email.me> <3575addb-2169-471a-8ff0-ef3d158fb901n@googlegroups.com>
Injection-Date: Mon, 10 Apr 2023 20:49:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7045023f708c7d7f9994625a872db533";
logging-data="2436770"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18G/mFyFHKSEdkWEjVpCFAY"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.19 (x86_64))
Cancel-Lock: sha1:i9BJUcjnSpCfQ30qIdgQyMgnlA0=
 by: Rich - Mon, 10 Apr 2023 20:49 UTC

Shaun Kulesa <shaunkulesa@gmail.com> wrote:
> Unfortunately the argument has to be in bytes.
>
> I changed the tcl server receive function to do 3 outputs to match
> the inputs given by the python client but none of them had the input
> message from the client as they were all empty strings.
>
> proc receive {channel} {
> puts [chan gets $channel]
> flush $channel
> puts [chan gets $channel]
> flush $channel
> puts [chan gets $channel]
> flush $channel
>
> close $channel
> }

Reread the Tcl 'gets' man page, specifically the part about
'non-blocking' IO.

If channelId is in non-blocking mode and there is not a full
line of input available, the command returns an empty string and
does not consume any input.

In 'non-blocking' mode, returning "empty string" is Tcl's way of
indicating "not a full line available".

If you use the alternate gets call, with a varname into which to store
the string, then you'll receive -1 as the length from gets when it
returns the "not enough data for a full line" indication.

Re: Tcl server receiving empty string from python client

<u11ss9$2abl2$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21703&group=comp.lang.tcl#21703

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Tcl server receiving empty string from python client
Date: Mon, 10 Apr 2023 20:51:21 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <u11ss9$2abl2$2@dont-email.me>
References: <488eaffc-cb9d-4021-a81c-586610af2699n@googlegroups.com> <u11q7s$2a0p2$1@dont-email.me> <701a09a4-7d07-43b3-adc9-04837a9f363bn@googlegroups.com>
Injection-Date: Mon, 10 Apr 2023 20:51:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7045023f708c7d7f9994625a872db533";
logging-data="2436770"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4o6nywE0aJMFtxg1913ND"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.19 (x86_64))
Cancel-Lock: sha1:ho9QRhysRdcTmgdgCb2QHLfFNgI=
 by: Rich - Mon, 10 Apr 2023 20:51 UTC

Shaun Kulesa <shaunkulesa@gmail.com> wrote:
> I got it to work as it closes the socket connection but the receive
> function continues to run causing an error as the channel no longer
> exists.
>
> python input:
>
> -> hello
> -> hello again
>
> tcl output:
>
> 87.115.149.231 joined
> Got: hello
> Got: hello again
> Got:
> Client has disconnected.
> can not find channel named "sock5573b3ce5050"
> while executing
> "read $channel"
> (procedure "receive" line 8)
> invoked from within
> "receive sock5573b3ce5050"
>
> receive function:
>
> proc receive {channel} {
> if {[eof $channel]} {
> close $channel
> puts "Client has disconnected."
> }
>
> puts "Got: [read $channel]"
> flush $channel
> }

Move your 'eof' to after the read. The [eof] signal only arrives
*after* you attempt to perform a read from the channel.

This is also documented in the [eof] manpage:

Returns 1 if an end of file condition occurred during the most
recent input operation on channelId (such as gets), 0 otherwise.

Re: Tcl server receiving empty string from python client

<d9f5ba4f-62b8-412d-8ca8-149af221f480n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21704&group=comp.lang.tcl#21704

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ac8:58cc:0:b0:3e6:970e:a405 with SMTP id u12-20020ac858cc000000b003e6970ea405mr2972034qta.6.1681161574448;
Mon, 10 Apr 2023 14:19:34 -0700 (PDT)
X-Received: by 2002:ac8:5713:0:b0:3e6:6502:16a5 with SMTP id
19-20020ac85713000000b003e6650216a5mr104640qtw.13.1681161574213; Mon, 10 Apr
2023 14:19:34 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 10 Apr 2023 14:19:33 -0700 (PDT)
In-Reply-To: <u11ss9$2abl2$2@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=87.115.149.231; posting-account=Be2r4goAAACg4Ko_BkJ0V-RlkGAdXGng
NNTP-Posting-Host: 87.115.149.231
References: <488eaffc-cb9d-4021-a81c-586610af2699n@googlegroups.com>
<u11q7s$2a0p2$1@dont-email.me> <701a09a4-7d07-43b3-adc9-04837a9f363bn@googlegroups.com>
<u11ss9$2abl2$2@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d9f5ba4f-62b8-412d-8ca8-149af221f480n@googlegroups.com>
Subject: Re: Tcl server receiving empty string from python client
From: shaunkulesa@gmail.com (Shaun Kulesa)
Injection-Date: Mon, 10 Apr 2023 21:19:34 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1473
 by: Shaun Kulesa - Mon, 10 Apr 2023 21:19 UTC

Thank you for your explanations, it now works correctly.

Also thank you to saitology9 for spending your time trying to help me in the beginning.

87.115.149.231 joined
Got: hello
Got: hello2
Got:
Client has disconnected.


devel / comp.lang.tcl / Re: Tcl server receiving empty string from python client

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor