Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Multi-threaded console apps

Name: Anonymous 2008-04-19 17:57

What's the best way to do something like an IRC client where there's messages coming from the network you'll want to display without interrupting the user's input.

I'm using a toy language (MzScheme), so I don't have easy access to some curses library or ptys or anything like that...

Any ideas, or should I just give up and write a curses wrapper?  Can GNU Readline do anything like this?

Name: Anonymous 2008-04-19 17:58

sage this shit

Name: Anonymous 2008-04-19 17:58

sage

Name: Anonymous 2008-04-19 17:58

Fuck you.

Name: Anonymous 2008-04-19 17:58

back to /b/, please

Name: Anonymous 2008-04-19 17:59

Name: Anonymous 2008-04-19 17:59

>>5
Forgot your sage.

Name: Anonymous 2008-04-19 18:02

Oh, I haven't read SICP, and I won't do it because I don't read programming books.

The reason I'm using Scheme... well, I started the app off with C, and wanted GNU Guile scripting but had some problems with threading, and thought I might just write it in Scheme instead :/

Name: Anonymous 2008-04-19 18:03

>>8
No. You are not welcome here. Gtfo.

Name: Anonymous 2008-04-19 18:04

>>8
No. You are not welcome here. Gtfo.

Name: Anonymous 2008-04-19 18:07

>>10
Hi, been a long time lurker on this board.. but I feel I have to speak out at this moment.

Never on The 4Chan Programming board have I seen someone be so horrible and with no provocation, utterly appalling.

that was uncalled for and just plain rude.

Name: Anonymous 2008-04-19 18:09

Name: Anonymous 2008-04-19 18:10

Funny you saged this thread so much while you all still reply to even worse threads without a sage.

Name: Anonymous 2008-04-19 18:11

>>12
I was considering Haskell, but I'd really like REPL during execution for this project.  Also, Haskell isn't very fun when it comes to bits and shit.  (Scheme isn't much better.)

Name: Anonymous 2008-04-19 18:12

>>11
Visit us on #sicp at EFnet and we can discuss your problem together. These heartless morons are useless.

Name: Anonymous 2008-04-19 18:15

>>2-7,9-11
A thread actually about programming, and you respond with sages and irrelevant memes. I don't care if I've been trolled, beet tolled or bean rolled, you suck.

Name: Anonymous 2008-04-19 18:20

>>16
Sage for whining

Name: Anonymous 2008-04-19 18:22

>>14
bits and shit
What is that?

I wrote a simple multithreaded IRC server in Haskell: http://monkeyboy.td.org.uit.no/~cin/code/hircd/

You can use hsplugins for a REPL. Or you could link to the greasespot Javascript library and script your IRC client with Javascript.

But, if you really want to use Scheme, threading and networking is easy, I've also written an IRCd in Scheme, too. Finding an ncurses wrapper would be your biggest issue. If you can't find one, you can probably write a simple ncurses wrapper library in C and control it from Scheme in a more high-level fashion.

Name: Anonymous 2008-04-19 18:23

you could have two threads per irc connection: one for reading
the input and one for reading the output

mzscheme is a decent scheme interpreter, i wouldn't give up on
it just yet (it has a great helpdesk, mred might be relevant).
you could easily build a very extensible IRC client with
it. i'm dreaming of something like this right now:

ENTERPRISE SCHEME IRC CLIENT

/join #prog
/(eval-command (lookup "join") (list "#prog"))

hello
/(privmsg "#prog" "hello")
/(raw "PRIVMSG #prog :hello")

/(add-handler 'on-privmsg (lambda (source target msg) ...)

/(map (lambda (x)
        (if (not (eq? x (me)))
          (kick "#thread" x "GTFO")
          '()))
      (inhabitants "#thread"))


i admit it would be more [i]l33t[i] to run
it through a terminal, but this would involve a lot more work.
you can do this later, i'd start off with a small gui in mred
(especially if you don't have any experience with scheme).

Name: Anonymous 2008-04-19 18:23

>>17
rage for saging

Name: Anonymous 2008-04-19 18:24

Sage this shit. Why are you replying to this shit thread?

Name: Anonymous 2008-04-19 18:25

>>18
Or just use Python, which would give you a REPL, too.

Or use Chicken Scheme:

http://chicken.wiki.br/ncurses

http://chicken.wiki.br/irc

Name: Anonymous 2008-04-19 18:25

>>21
Seconded

Name: Anonymous 2008-04-19 18:26

Sage

Name: Anonymous 2008-04-19 18:27

>>21,23
Go away. You should be able to ignore it if it bothers you, being so busy making interesting and stimulating discussions elsewhere.

Name: Anonymous 2008-04-19 18:28

>>18
bits and shit
What is that?
Well, first I have to decompress the Huffman-compressed packets I receive, then I have to find the correct bytes in the packets and flip the byte order (but not in all cases).

As for the input issue... it seems readline can do this somehow, but it'll require some hacking, at least creating a custom output port I think.

http://tiswww.case.edu/php/chet/readline/readline.html#SEC35

Name: Anonymous 2008-04-19 18:29

>>19
You could do that purely from a REPL inside DrScheme.

Name: Anonymous 2008-04-19 18:32

>>26
You should use STM. Is the REPL that important? Haskell's HsPlugins could provide that. Using STM would do the operations atomically, meaning you could use one input port after all.

Name: Anonymous 2008-04-19 18:47

>>28
Not only do I want a REPL for easy hacking, I also want easy scripting.  Haskell isn't Desktop-ready yet.

Name: Anonymous 2008-04-19 18:50

you don't have to multithread an irc client, everything sent from the irc-server is line for line, even stuff in other channels, you just put it in the correct channel buffer by looking at which channel it belongs to PRIVMSG #channel

Name: Anonymous 2008-04-19 18:55

>>30
multiple servers

Name: Anonymous 2008-04-19 18:57

>>31
man select

Name: Anonymous 2008-04-19 19:34

>>32
maybe I don't want to use select. maybe I like threads

Name: Anonymous 2008-04-19 19:38

>>33
Now you have two problems

Name: Anonymous 2008-04-19 19:44

>>34
Now you  have     to  follow this   with    your     mouse to REVEAL my answer: _    __________I HAVE BEEN TROLLING YOU AND THE SUSSMAN ALL ALONG

Name: Anonymous 2008-04-19 19:57

>>35
No I don't. All your spoilers are revealed for I use w3m.

Name: Anonymous 2008-04-19 20:03

>>36
YOU ARE A BARE-FACED LIAR and I am using a pocket calculator that I made into a LISP Machinetm.

Name: Anonymous 2008-04-19 20:20

>>35
All I have to do is highlight the text and it's revealed. Alternatively, since I'm using the Opera browser (www.opera.com) I can disable stylesheets and I can see your text.

www.opera.com

Name: Anonymous 2008-04-19 20:23

>>38
All I have to do is highlight the text and it's revealed.
THANKS FER THE TIP I NEVER REALIZZARD ~IT PROBABLY DUSNT WORK IN MY BROWSER OR ANYTHING1

1 www.getfirefox.com

Name: Anonymous 2008-04-19 20:25

>>39
I regret to inform you but you are using an inferior browser.

www.opera.com

Name: Anonymous 2008-04-19 20:28

WHAT MEANS wwæø».com? PERHAPS YOUR BROWSER'S ENCODING IS INCORRECT

Name: Anonymous 2008-04-19 20:37

there's messages coming from the network you'll want to display without interrupting the user's input
Use erlang, faggot. I can't imagine you're even thinking about something else.

Name: Anonymous 2008-04-20 4:43

>>42
Wouldn't that be a bit overkill?

Name: Anonymous 2008-04-20 5:13

>>43
No.

Name: Anonymous 2008-04-20 5:38

>>37
somebody's been practicing their bbcode more than their programming

select > threads in this case

Name: Anonymous 2008-04-20 5:43

>>42


*** Peter has joined #erlang
[14:16] <John> Hello Peter
[14:16] <Peter> Hello John
[14:17] <Steve> Hello Peter
[14:17] <John> Hello Steve
[14:18] <Peter> Hello Steve

Name: Anonymous 2008-04-20 6:06

>>45
BBCODE is /prog/ramming.

Name: Anonymous 2008-04-20 6:31

>>45
Exactly how would you do the terminal input with select?

Name: Anonymous 2008-04-20 7:31

Launch one thread that keep read()'ing the socket.

AND YOU'RE DONE !

Name: Anonymous 2008-04-20 8:11

>>49
I implemented that (the actual thread is the REPL), and it does break input, as I expected.  I haven't been able to get the readline functions I linked above to do anything worthwhile :/

Name: Anonymous 2008-04-20 13:18

> (0) Demon Arkanis: yo
(0) Demon Arkanis: i just killed wylan
(0) Spinalfury: hey
(0) Spinalfury: nice
(0) Spinalfury: lol
(0) Spinalfury: he was pissed im sure
(0) Demon Arkanis: he was afk macroing in his house and had a macro to heal himself
(0) Spinalfury: hey
(0) Demon Arkanis: so i got 3 characters and set up macros to throw GE's and cast earthquake
(0) Demon Arkanis: at same time

Name: Anonymous 2008-04-20 15:18

(for-each
  (lambda (x)
    (sleep 3)
    (action-say x)) ; delicious side-effects
  '("HAHAHAHAHAHAHAHHAHAHAHAAHAHAAAA!!!"
  "you think your tough huh?"
  "two words Sussman and Abelson."
  "i have written two programming books at the same time in less than 5 seconds i have been training for 3 years."
  "also SICP,On Lisp,and TAoCP."
  "you might be stronger than me,but i know im smarterer and quicker with shift-0."
  "i only weigh 130 pounds pure lean parentheses."
  "one argument you'll be on your way to reread SICP."
  "your the one whose a homo.i can get Julie Sussman anytime i want you probably haven't ever been laid before."
  "you probably have sex with your REPL."
  "you don't even know me,and you don't want to."
  "you'll be lucky if your even worth the apply one lambda and you'll recurse forever."
  "though i'd be hapy to humiliate you in front of all your friends."
  "btw IM the best."
  "i have trolled in Slashdot, Reddit, Digg,paulgraham.com, Craigslist,MIT,world4chan.org."
  "never lost an internet fight!"
  "im undefeated in competitive forced indentation/parenthesis counting."
  "im on my way to Nirvana."
  "go ahead and come step anytime you want.b*tch"))

Name: Anonymous 2008-04-21 14:36

All right, I seem to have tamed readline:

  puts("\e[M\rasd");          /* clear line, go to beginning of line, output asd, go to next line */
  rl_forced_update_display(); /* this redraws the readline prompt, nothing else works with the above commands */


Now I'll just have to see if this works as well with MzScheme's readline wrapper, and how to automatically do this when outputting text.

Name: Anonymous 2008-04-21 15:00

Hm, it does work, I suppose... but when you execute some commands, shit happen :)

(define rl-forced-update-display
  (get-ffi-obj "rl_forced_update_display" libreadline (_fun -> _void)))

(define (messagef format . args)
  (display "\e[M\r")
  (apply printf (cons format args))
  (newline)
  (rl-forced-update-display))


Good enough for now.

Name: wedding 2010-06-07 1:05


It’s so much easier to  find the perfect <a href="http://www.eastbridal.com/">wedding dresses</a><a href="http://weddings.lovetoknow.com/wiki/Bridal_Party_Dresses" title="Bridal Party Dresses"></a> dress  today than it was 20 or 40 years ago. <a href="http://www.eastbridal.com/">wedding dress</a> are the days of puffy shoulder pads  and<a href="http://www.eastbridal.com/">discount wedding dresses</a>, today’s bridesmaids’ dresses are sleek and streamlined, many  of <a href="http://www.eastbridal.com/designer-wedding-dress/beach-wedding-dresses.html">beach wedding dresses</a> can be worn again. <a href="http://www.eastbridal.com/designer-wedding-dress/simple-wedding-dress.html">Simple wedding dress</a> have also evolved, saying goodbye to gaudy  shades in favor of a huge color spectrum ranging from elegant<a href="http://www.eastbridal.com/designer-wedding-dress/modest-wedding-dress.html"> Modest wedding dress</a> to  sophisticated fun pinks and fresh<a href="http://www.eastbridal.com/designer-wedding-dress/elegant-wedding-dress.html">Elegant wedding dress</a>.Generally the<a href="http://www.eastbridal.com/designer-wedding-dress/elegant-wedding-dress.html">Elegant wedding dress</a>chooses  the type of dress her bridesmaids will wear.<a href="http://www.eastbridal.com/designer-wedding-dress/elegant-wedding-dress.html">Elegant wedding dress</a> is often a bone of contention  for the bridesmaids as many times the <a href="http://www.eastbridal.com/designer-wedding-dress/chinese-wedding-dress.html">Chinese wedding dress </a> chooses a style or color that isn’t  flattering for all of the women in the <a href="http://www.eastbridal.com/designer-wedding-dress/western-wedding-dress.html">Western wedding dress</a> party. While it’s true, you  can’t please everyone, the <a href="http://www.eastbridal.com/designer-wedding-dress/formal-wedding-dress.html">Formal wedding dress</a> can spare a lot of bad feelings by allowing  the women in the<a href="http://www.eastbridal.com/designer-wedding-dress/informal-wedding-dress.html">Informal wedding dress</a> party to have some input into the selection process. Perhaps  all of the women involved can have<a href="http://www.eastbridal.com/wedding-dress-style.html">Wedding dress style</a> of shopping together to find  a style and <a href="http://www.eastbridal.com/wedding-dress-style/short-wedding-dress.html">Short wedding dress</a> flattering to every shape and skin tone. Try to find styles  without too many <a href="http://www.eastbridal.com/wedding-dress-style/tea-length-wedding-dress.html">Tea length wedding dress</a> or embellishments as these types of dresses can’t be  cut down or worn again for other <a href="http://www.eastbridal.com/wedding-dress-style/tea-length-wedding-dress.html">Tea length wedding dress </a> occasions.If you want to find a <a href="http://www.eastbridal.com/wedding-dress-style/strapless-wedding-dress.html">Strapless wedding dress</a> flattering to  everyone, avoid the <a href="http://www.eastbridal.com/wedding-dress-style/straps-wedding-dress.html">Straps wedding dress</a>: Puffy shoulder pads: Big <a href="http://www.eastbridal.com/wedding-dress-style/short-sleeves-wedding-dress.html">Short wedding dress sleeves</a> flatter very  few women. Petite women seem lost in the <a href="http://www.eastbridal.com/wedding-dress-style/mermaid-wedding-dress.html">Mermaid wedding dress </a> and larger framed women  look like <a href="http://www.eastbridal.com/wedding-dress-style/column-wedding-dress.html">Column wedding dress </a>. If you’d like all your <a href="http://www.eastbridal.com/wedding-dress-style/plus-size-wedding-dresses.html">Plus Size wedding dresses </a> to look lovely, avoid  the use of heavily padded <a href="http://www.eastbridal.com/wedding-dress-colors.html">Wedding dress colors</a>. Large “butt” bows: You have to have a  small <a href="http://www.eastbridal.com/wedding-dress-colors/white-wedding-dress.html">White wedding dress</a> to rock the butt bow. Since <a href="http://www.eastdress.com/">Prom Dresses</a> is an area most women don’t  wish to call <a href="http://www.eastdress.com/">Cheap Prom Dress</a> to, try not to choose <a href="http://www.eastdress.com/">Prom Dresses 2010</a> with large butt bows. Pale  Colors: Pale <a href="http://www.eastdress.com/">Prom Dress</a> and <a href="http://www.eastdress.com/prom-dresses-2010_c360">Prom Dresses 2010</a> might look good on the <a href="http://www.eastdress.com/cheap-prom-dresses_c358">Cheap Prom Dresses</a>, but <a href="http://www.eastdress.com/plus-size-prom-dresses_c351">Plus Size Prom Dresses</a> don’t  work for all skin types. Women with very light <a href="http://www.eastdress.com/short-prom-dresses_c352">Short Prom Dresses</a> will look washed out,  especially in <a href="http://www.eastdress.com/short-prom-dresses_c352">Short Prom Dresses</a>.What will you do with  your <a href="http://www.eastdress.com/vintage-prom-dresses_c353">Vintage Prom Dresses</a> after the wedding? If it’s a formal <a href="http://www.eastdress.com/sexy-prom-dresses_c354">Sexy Prom Dresses</a> and you would like  to keep in its pristine <a href="http://www.eastdress.com/simple-prom-dresses_c356">Simple Prom Dresses</a> to wear to another formal <a href="http://www.eastdress.com/designer-prom-dresses_c357">Designer Prom Dresses</a> in the future,  consider bringing it to a <a href="http://www.eastdress.com/quinceanera-dresses_c359">Quinceanera Dresses</a> preservation specialist.

Name: Anonymous 2010-11-15 2:01

Name: Sgt.Kabukiman 2012-05-22 23:04

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Name: Anonymous 2013-01-19 23:49

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Don't change these.
Name: Email:
Entire Thread Thread List