[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gforth] socket.fs getting started problem
From: |
Bernd Paysan |
Subject: |
Re: [gforth] socket.fs getting started problem |
Date: |
Tue, 17 Apr 2012 23:27:06 +0200 |
User-agent: |
KMail/4.7.2 (Linux/3.1.9-1.4-desktop; KDE/4.7.2; x86_64; ; ) |
Am Dienstag, 17. April 2012, 10:25:13 schrieb kibler:
> The version of gforth I am using:
> > gforth
>
> Gforth 0.7.9-20120317, Copyright (C) 1995-2011 Free Software Foundation,
> Inc.
>
> The test code based on repost.fs to just open a socket for reading:
>
> \ test.fs - test to see if can open a socket...
> require unix/socket.fs
>
> 2000 constant nntp
>
> 1024 constant status-buf-len
> create status-buf status-buf-len 2 + chars allot
>
> : read-status { sock -- ior }
>
> sock stdout = if \ for debugging
> 0 exit endif
> status-buf status-buf-len sock read-line throw 0= -39 and throw { len }
> status-buf c@ [char] 1 [char] 3 1+ within if
> status-buf len type cr
> 0
> else
> status-buf len type cr
> -21 \ unsupported operation
> endif ;
>
> : repostx
>
> s" 127.0.0.1 " 2000 open-socket sock !
> ;
This fails to compile, since sock is not defined.
> : repost
>
> parse-name { d: server }
> server nntp open-socket { sock }
> sock read-status throw
> \ s" AUTHINFO USER " sock write-file throw user sock write-line throw
> sock read-status throw
> \ s" AUTHINFO PASS " sock write-file throw passwd sock write-line throw
> sock read-status throw
> \ start-id articles start-articles sock process-articles
> \ s" QUIT" sock write-line throw
> sock read-status throw
> sock close-file throw ;
>
> A couple of tests and their results:
Ok, here's my test and my result:
Running "nc -l 2000" on one terminal, and gforth test.fs on another terminal:
repost localhost 123
234
345
123
ok
The numbers here are what I entered (should all start with 1 to 3).
Honestly, I have absolutely no clue at all what fails so horribly on your
system, because unix/socket.fs is something I use daily, and get-info is
certainly required, especially applied to localhost.
There is nothing wrong with your way of using open-socket and friends.
What could be possilbe is that you have an old socket.so.* in your
~/.gforth/libcc-named/.libs, which is not compatible with the new pthread-
enabled engine. But then, a proper make install will install you a
socket.so.* for the new engine, and it won't look up ~/.gforth/libcc-
named/.libs. Just in case, remove ~/.gforth, and try again.
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/
signature.asc
Description: This is a digitally signed message part.