[racket] Fwd: What is racket/cmdline?

From: Danny Yoo (dyoo at hashcollision.org)
Date: Wed Apr 10 11:34:29 EDT 2013

---------- Forwarded message ----------
From: deepak verma <deepakverma14021994 at gmail.com>
Date: Wed, Apr 10, 2013 at 4:53 AM
Subject: Re: What is racket/cmdline?
To: Danny Yoo <dyoo at hashcollision.org>


next time i will remember to write the subject

and actually i only know about graphical interface..

and as far as documentation is concerned ... i read it approximately
3-4 hrs daily but..
it is really hard to grasp things out of it.



let me show u a code.




(define (serve port-no state)
  (define listener (tcp-listen 1985 5 true "10.4.233.9"))
  (define (loop)
    (accept-and-handle listener state)
    (loop))
  (define t (thread loop))
  (lambda ()
    t
    (kill-thread t)
    (tcp-close listener)))

(define (accept-and-handle listener state)
  (define-values (in out) (tcp-accept listener))
  (thread
   (lambda ()
     (handle in out state)
     (close-input-port in)
     (close-output-port out))))


(define (handle in out state)
  (begin (display state out)
         (flush-output out)))

;;;;;here state is any string i would like to send .



i am trying to read the output from other computer using the tcp-connect.
but it is not showing output until i run the listner console again.


for tcp-connect
my code is :

 (define-values (sin sout) (tcp-connect "10.4.233.9" 1985))

and i write (read sin )
 in console .


On Tue, Apr 9, 2013 at 11:07 PM, Danny Yoo <dyoo at hashcollision.org> wrote:
>
> Deepak, please place a useful subject line on your emails.  Right now,
> your emails have no subject line, which makes it difficult for people
> to judge whether or not the question is interesting to them.  I'm
> changing the subject line to "What is cmdline?".
>
> ---
>
> It's a bit hard to answer this question without you telling us some
> background on what you already know.  Are you already familiar with
> the command-line interface of certain operating systems, or are you
> only familiar with a graphical user interface?
>
>
> If there's a function you don't quite know, DrRacket provides fairly
> extensive documentation if you use your mouse and right-click the name
> of the function.
>
> In this case, command-line has documentation here:
>
>     http://docs.racket-lang.org/reference/Command-Line_Parsing.html
>
> It's a library to manage some of the messiness of parsing command line
> arguments to a program.  When a program is executed from the command
> line (http://docs.racket-lang.org/guide/scripts.html), the user can
> provide additional command line arguments to provide initial inputs
> into the program.
>
>
> These arguments are passed as a parameter to the program,
> current-command-line-arguments,
>
>     http://docs.racket-lang.org/reference/runtime.html#%28def._%28%28quote._~23~25kernel%29._current-command-line-arguments%29%29
>
> but we would like to deal with that vector of strings in a way
> consistent with other command-line tools.  e.g. provide a good
> "--help", print good error messages when the user passes bad
> arguments, etc.  The racket/cmdline library, and the command-line
> function that it provides, are tools to help make these convenient to
> implement.

Posted on the users mailing list.