unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* open-socket-for-uri returns string, but integer is needed
@ 2021-01-30 13:35 mbcladwell
  2021-01-30 14:29 ` Aleix Conchillo Flaqué
  0 siblings, 1 reply; 5+ messages in thread
From: mbcladwell @ 2021-01-30 13:35 UTC (permalink / raw)
  To: guile-user


Hi,
On Debian 10, Guile 3.0.4 I need to create a socket:

mbc@HP8300:~$ guile
GNU Guile 3.0.4
Copyright (C) 1995-2020 Free Software Foundation, Inc.
Enter `,help' for help.
scheme@(guile-user)> (use-modules (web client))
scheme@(guile-user)> (open-socket-for-uri  
"https://blockchain.info/q/24hrprice")
$1 = #<input-output: file 7f09b60b0e00>
scheme@(guile-user)> (open-socket-for-uri "http://localhost:3000/123")
$2 = #<input-output: socket 14>
scheme@(guile-user)>

A local http looks good - returns an integer socket.
A remote https uri returns file 7f09b60b0e00 which is rejected by  
downstream functions requiring a port/integer e.g. (http-get ....  
#:port )

I get the same results on Guile 2.2.7 in a Guix protected environment.
What am I doing wrong - how do I get an integer returned?
Thanks
Mortimer




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: open-socket-for-uri returns string, but integer is needed
  2021-01-30 13:35 open-socket-for-uri returns string, but integer is needed mbcladwell
@ 2021-01-30 14:29 ` Aleix Conchillo Flaqué
  2021-01-30 15:23   ` mbcladwell
  0 siblings, 1 reply; 5+ messages in thread
From: Aleix Conchillo Flaqué @ 2021-01-30 14:29 UTC (permalink / raw)
  To: mbcladwell; +Cc: guile-user

Hi,

This is just a guess but do you have GnuTLS Guile bindings installed? You
are using https on the first one.

In Debian I believe it's guile-gnutls.

Best,

Aleix


On Sat, Jan 30, 2021, 5:38 AM <mbcladwell@stihie.net> wrote:

>
> Hi,
> On Debian 10, Guile 3.0.4 I need to create a socket:
>
> mbc@HP8300:~$ guile
> GNU Guile 3.0.4
> Copyright (C) 1995-2020 Free Software Foundation, Inc.
> Enter `,help' for help.
> scheme@(guile-user)> (use-modules (web client))
> scheme@(guile-user)> (open-socket-for-uri
> "https://blockchain.info/q/24hrprice")
> $1 = #<input-output: file 7f09b60b0e00>
> scheme@(guile-user)> (open-socket-for-uri "http://localhost:3000/123")
> $2 = #<input-output: socket 14>
> scheme@(guile-user)>
>
> A local http looks good - returns an integer socket.
> A remote https uri returns file 7f09b60b0e00 which is rejected by
> downstream functions requiring a port/integer e.g. (http-get ....
> #:port )
>
> I get the same results on Guile 2.2.7 in a Guix protected environment.
> What am I doing wrong - how do I get an integer returned?
> Thanks
> Mortimer
>
>
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: open-socket-for-uri returns string, but integer is needed
  2021-01-30 14:29 ` Aleix Conchillo Flaqué
@ 2021-01-30 15:23   ` mbcladwell
  2021-01-30 19:23     ` Aleix Conchillo Flaqué
  0 siblings, 1 reply; 5+ messages in thread
From: mbcladwell @ 2021-01-30 15:23 UTC (permalink / raw)
  To: Aleix Conchillo Flaqué; +Cc: guile-user

Yes it is installed.

mbc@HP8300:~$ dpkg -s guile-gnutls
Package: guile-gnutls
Status: install ok installed

How do I test that it is properly configured? For example I can:

scheme@(guile-user)> (cdar (json-string->scm (utf8->string (receive  
(response-status response-body)
	  (http-request  
"https://api.blockchain.com/v3/exchange/tickers/LTC-USD")  
response-body))))
$1 = 134.3

Thanks
Mortimer

Quoting Aleix Conchillo Flaqué <aconchillo@gmail.com>:

> Hi,
>
> This is just a guess but do you have GnuTLS Guile bindings installed? You
> are using https on the first one.
>
> In Debian I believe it's guile-gnutls.
>
> Best,
>
> Aleix
>
>
> On Sat, Jan 30, 2021, 5:38 AM <mbcladwell@stihie.net> wrote:
>
>>
>> Hi,
>> On Debian 10, Guile 3.0.4 I need to create a socket:
>>
>> mbc@HP8300:~$ guile
>> GNU Guile 3.0.4
>> Copyright (C) 1995-2020 Free Software Foundation, Inc.
>> Enter `,help' for help.
>> scheme@(guile-user)> (use-modules (web client))
>> scheme@(guile-user)> (open-socket-for-uri
>> "https://blockchain.info/q/24hrprice")
>> $1 = #<input-output: file 7f09b60b0e00>
>> scheme@(guile-user)> (open-socket-for-uri "http://localhost:3000/123")
>> $2 = #<input-output: socket 14>
>> scheme@(guile-user)>
>>
>> A local http looks good - returns an integer socket.
>> A remote https uri returns file 7f09b60b0e00 which is rejected by
>> downstream functions requiring a port/integer e.g. (http-get ....
>> #:port )
>>
>> I get the same results on Guile 2.2.7 in a Guix protected environment.
>> What am I doing wrong - how do I get an integer returned?
>> Thanks
>> Mortimer
>>
>>
>>






^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: open-socket-for-uri returns string, but integer is needed
  2021-01-30 15:23   ` mbcladwell
@ 2021-01-30 19:23     ` Aleix Conchillo Flaqué
  2021-01-31  8:27       ` mbcladwell
  0 siblings, 1 reply; 5+ messages in thread
From: Aleix Conchillo Flaqué @ 2021-01-30 19:23 UTC (permalink / raw)
  To: mbcladwell; +Cc: guile-user

Hi,

I've tried this on macOS and I get the following (note the port type
is not socket, but neither file):

scheme@(guile-user)> (open-socket-for-uri "https://blockchain.info/q/24hrprice")
$7 = #<input-output: string 105b0c540>

If I do the following I get an error (see below):

scheme@(guile-user)> (define s (open-socket-for-uri
"https://blockchain.info/q/24hrprice"))

wait a bit... then:

scheme@(guile-user)> (http-request
"https://blockchain.info/q/24hrprice" #:port s)
ice-9/boot-9.scm:1669:16: In procedure raise-exception:
Bad Read-Header-Line header: #<eof>

However, if I do the following:

scheme@(guile-user)> (http-request
"https://blockchain.info/q/24hrprice" #:port (open-socket-for-uri
"https://blockchain.info/q/24hrprice"))

The request works fine. So, if I do the following quickly enough:

scheme@(guile-user)> (define s (open-socket-for-uri
"https://blockchain.info/q/24hrprice"))
scheme@(guile-user)> (http-request
"https://blockchain.info/q/24hrprice" #:port s)

it works fine. So it seems a timing issue.

What is exactly failing and when in your case?

Aleix

On Sat, Jan 30, 2021 at 7:23 AM <mbcladwell@stihie.net> wrote:
>
> Yes it is installed.
>
> mbc@HP8300:~$ dpkg -s guile-gnutls
> Package: guile-gnutls
> Status: install ok installed
>
> How do I test that it is properly configured? For example I can:
>
> scheme@(guile-user)> (cdar (json-string->scm (utf8->string (receive
> (response-status response-body)
>           (http-request
> "https://api.blockchain.com/v3/exchange/tickers/LTC-USD")
> response-body))))
> $1 = 134.3
>
> Thanks
> Mortimer
>
> Quoting Aleix Conchillo Flaqué <aconchillo@gmail.com>:
>
> > Hi,
> >
> > This is just a guess but do you have GnuTLS Guile bindings installed? You
> > are using https on the first one.
> >
> > In Debian I believe it's guile-gnutls.
> >
> > Best,
> >
> > Aleix
> >
> >
> > On Sat, Jan 30, 2021, 5:38 AM <mbcladwell@stihie.net> wrote:
> >
> >>
> >> Hi,
> >> On Debian 10, Guile 3.0.4 I need to create a socket:
> >>
> >> mbc@HP8300:~$ guile
> >> GNU Guile 3.0.4
> >> Copyright (C) 1995-2020 Free Software Foundation, Inc.
> >> Enter `,help' for help.
> >> scheme@(guile-user)> (use-modules (web client))
> >> scheme@(guile-user)> (open-socket-for-uri
> >> "https://blockchain.info/q/24hrprice")
> >> $1 = #<input-output: file 7f09b60b0e00>
> >> scheme@(guile-user)> (open-socket-for-uri "http://localhost:3000/123")
> >> $2 = #<input-output: socket 14>
> >> scheme@(guile-user)>
> >>
> >> A local http looks good - returns an integer socket.
> >> A remote https uri returns file 7f09b60b0e00 which is rejected by
> >> downstream functions requiring a port/integer e.g. (http-get ....
> >> #:port )
> >>
> >> I get the same results on Guile 2.2.7 in a Guix protected environment.
> >> What am I doing wrong - how do I get an integer returned?
> >> Thanks
> >> Mortimer
> >>
> >>
> >>
>
>
>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: open-socket-for-uri returns string, but integer is needed
  2021-01-30 19:23     ` Aleix Conchillo Flaqué
@ 2021-01-31  8:27       ` mbcladwell
  0 siblings, 0 replies; 5+ messages in thread
From: mbcladwell @ 2021-01-31  8:27 UTC (permalink / raw)
  To: Aleix Conchillo Flaqué; +Cc: guile-user

I confirm that I get the same results as you with respect to timing.   
I suspect a configuration issue because other colleagues report that

(open-socket-for-uri "https://blockchain.info/q/24hrprice")

returns a socket integer.  I (and you) get a string.

I need to retrieve the uri output on a non-blocking port so I am trying to:

(let* ((port (open-socket-for-uri "https://blockchain.info/q/24hrprice"))
        (portmod (fcntl port F_SETFL (logior O_NONBLOCK (fcntl port  
F_GETFD 0)))))
   (receive (response-status response-body)
       (http-get "https://blockchain.info/q/24hrprice" #:port portmod)  
response-body))

Even making it a one-liner does not help:

  (receive (response-status response-body) (http-get  
"https://blockchain.info/q/24hrprice" #:port  (fcntl  
(open-socket-for-uri "https://blockchain.info/q/24hrprice") F_SETFL  
(logior O_NONBLOCK (fcntl (open-socket-for-uri  
"https://blockchain.info/q/24hrprice") F_GETFD 0)))) response-body)

  Thanks
  Mortimer

Quoting Aleix Conchillo Flaqué <aconchillo@gmail.com>:

> Hi,
>
> I've tried this on macOS and I get the following (note the port type
> is not socket, but neither file):
>
> scheme@(guile-user)> (open-socket-for-uri  
> "https://blockchain.info/q/24hrprice")
> $7 = #<input-output: string 105b0c540>
>
> If I do the following I get an error (see below):
>
> scheme@(guile-user)> (define s (open-socket-for-uri
> "https://blockchain.info/q/24hrprice"))
>
> wait a bit... then:
>
> scheme@(guile-user)> (http-request
> "https://blockchain.info/q/24hrprice" #:port s)
> ice-9/boot-9.scm:1669:16: In procedure raise-exception:
> Bad Read-Header-Line header: #<eof>
>
> However, if I do the following:
>
> scheme@(guile-user)> (http-request
> "https://blockchain.info/q/24hrprice" #:port (open-socket-for-uri
> "https://blockchain.info/q/24hrprice"))
>
> The request works fine. So, if I do the following quickly enough:
>
> scheme@(guile-user)> (define s (open-socket-for-uri
> "https://blockchain.info/q/24hrprice"))
> scheme@(guile-user)> (http-request
> "https://blockchain.info/q/24hrprice" #:port s)
>
> it works fine. So it seems a timing issue.
>
> What is exactly failing and when in your case?
>
> Aleix
>
> On Sat, Jan 30, 2021 at 7:23 AM <mbcladwell@stihie.net> wrote:
>>
>> Yes it is installed.
>>
>> mbc@HP8300:~$ dpkg -s guile-gnutls
>> Package: guile-gnutls
>> Status: install ok installed
>>
>> How do I test that it is properly configured? For example I can:
>>
>> scheme@(guile-user)> (cdar (json-string->scm (utf8->string (receive
>> (response-status response-body)
>>           (http-request
>> "https://api.blockchain.com/v3/exchange/tickers/LTC-USD")
>> response-body))))
>> $1 = 134.3
>>
>> Thanks
>> Mortimer
>>
>> Quoting Aleix Conchillo Flaqué <aconchillo@gmail.com>:
>>
>> > Hi,
>> >
>> > This is just a guess but do you have GnuTLS Guile bindings installed? You
>> > are using https on the first one.
>> >
>> > In Debian I believe it's guile-gnutls.
>> >
>> > Best,
>> >
>> > Aleix
>> >
>> >
>> > On Sat, Jan 30, 2021, 5:38 AM <mbcladwell@stihie.net> wrote:
>> >
>> >>
>> >> Hi,
>> >> On Debian 10, Guile 3.0.4 I need to create a socket:
>> >>
>> >> mbc@HP8300:~$ guile
>> >> GNU Guile 3.0.4
>> >> Copyright (C) 1995-2020 Free Software Foundation, Inc.
>> >> Enter `,help' for help.
>> >> scheme@(guile-user)> (use-modules (web client))
>> >> scheme@(guile-user)> (open-socket-for-uri
>> >> "https://blockchain.info/q/24hrprice")
>> >> $1 = #<input-output: file 7f09b60b0e00>
>> >> scheme@(guile-user)> (open-socket-for-uri "http://localhost:3000/123")
>> >> $2 = #<input-output: socket 14>
>> >> scheme@(guile-user)>
>> >>
>> >> A local http looks good - returns an integer socket.
>> >> A remote https uri returns file 7f09b60b0e00 which is rejected by
>> >> downstream functions requiring a port/integer e.g. (http-get ....
>> >> #:port )
>> >>
>> >> I get the same results on Guile 2.2.7 in a Guix protected environment.
>> >> What am I doing wrong - how do I get an integer returned?
>> >> Thanks
>> >> Mortimer
>> >>
>> >>
>> >>
>>
>>
>>






^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-31  8:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-30 13:35 open-socket-for-uri returns string, but integer is needed mbcladwell
2021-01-30 14:29 ` Aleix Conchillo Flaqué
2021-01-30 15:23   ` mbcladwell
2021-01-30 19:23     ` Aleix Conchillo Flaqué
2021-01-31  8:27       ` mbcladwell

unofficial mirror of guile-user@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-user/0 guile-user/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-user guile-user/ https://yhetil.org/guile-user \
		guile-user@gnu.org
	public-inbox-index guile-user

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.user
	nntp://news.gmane.io/gmane.lisp.guile.user


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git