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

Pages: 1-4041-

Telnet chat server

Name: Anonymous 2011-02-16 17:39

telnet 98.255.132.66 9099

Come join the fun!

Name: VIPPER 2011-02-16 17:47

Wish i could but i go sleeping now, good night.

Name: Anonymous 2011-02-16 17:51

I am sleeping now, can't join

Name: derp !y68oC3vPJM 2011-02-16 18:31

sage, the herpy derper

Name: Anonymous 2011-02-16 18:39

post src?

Name: Anonymous 2011-02-16 18:44

Source for the curious

chatter/main.go
http://pastebin.com/23KHtwyb

broadcast/broadcast.go
http://pastebin.com/HFaytEQK

Name: Anonymous 2011-02-17 0:20

.go
faggot

Name: Anonymous 2011-02-17 0:50

>>7
U JELLY?

Name: Anonymous 2011-02-17 9:35

>>7
i challenge /prog/ to remimplement OP's chatserver in a better env than GoogLe GO.

Name: Anonymous 2011-02-17 9:36

>>9
I could write it in one Lisp macro.

Name: Anonymous 2011-02-17 9:40

>>9
I would, but I can't read it.

Name: Anonymous 2011-02-17 10:06


I have better idea. Reimplement chatserver in fictional language of your choice.


using Socket; //socket io
using Thread; //threads are good
using AtomicVector; //each operation locks entire vector

var sock = Socket.listen(Socket.TCP4, 9999);
var clients = AtomicVector[Socket]();

fun broadcast(message, ignore) {
   clients.each { |client|
      try{
        client.send(message + "\n") unless client == ignore
      } except { /*NO EXCEPTIONS*/ }
   }
   println(message);
}

//
// main loop
//

while(true){
    var newUser = sock.accept();
    clients.add(newUser)        
    Thread.runLoop {
        try{
          var input = newUser.readBlocked().stripped()
          if input == EOF or input == "/quit"
              clients.delete(newUser)
          else
               broadcast(input, newUser);
        } except {
           clients.delete(newUser)
        }
    }
}


My non-existent language > go.

Name: Anonymous 2011-02-17 10:46

>>12
First with an existent programming language:
#lang racket
(require racket/tcp
         (only-in srfi/43 vector-for-each))

(define clients (make-vector 255 #f)) ; fixed length vector because I'm evil.
(define listener (tcp-listen 9999))

(struct client (id in out))

(define (broadcast message ignore-id)
  (vector-for-each
   (λ (cl)
     (unless (= ignore-id (client-id cl))
       (fprintf (client-out cl) "~a~n" message)))
   clients))

(define (add-client! in out)
  (with-handlers ((exn:fail:contract? (λ x (fprintf out "*** Exception: monadic pointer stack overflow")
                                        (close-output-port out) '|monadic pointer stack overflow|)))
    (let loop ((i 0))
      (if (vector-ref clients i) (loop (add1 i))
          (let ((cl (client i in out)))
            (vector-set! clients i cl) cl)))))

(define (delete-client! cl)
  (close-output-port (client-out cl))
  (vector-set! clients (client-id cl) #f))

(let loop ()
  (let ((client (call-with-values (lambda () (tcp-accept listener)) add-client!)))
    (unless (eq? client '|monadic pointer stack overflow|)
      (thread
       (lambda ()
         (let loop ((x (read-line (client-in client))))
           (cond ((or (eof-object? x)
                      (string-ci=? x "/quit"))
                  (delete-client! client))
                 (else
                  (broadcast x (client-id client))
                  (loop (read-line (client-in client))))))))))
  (loop))

Name: Anonymous 2011-02-17 10:48

>>12
fictional language:
(loop (broadcast (read (accept)))

Name: Anonymous 2011-02-17 12:27

>>6
I don't see any telnet implementation at all.  What are you trying to pull here, mister?

Also,
#!/usr/bin/perl
use 5.008001;
use base 'Net::Server::Multiplex';

sub mux_input {
    my ($self, $mux, $fh, $inbuf) = @_;
    while ($$inbuf =~ s/^(.*?)\r?\n//) {
        if ($1 eq "/quit") {
            $mux->close($fh);
        } else {
            my $bcast = $self->{peeraddr}.': '.$1."\r\n";
            for my $client ($mux->handles) {
                $mux->write($client, $bcast) unless $client == $fh;
            }
        }
    }
}

run main port => 9099

Name: Anonymous 2011-02-17 12:38

OP here, yeah, "telnet" is definitely a misnomer. I should have called it "netcat chat server" or something. You can use telnet to access the server, still, though, and that's the program more people are familiar with.

Name: Anonymous 2011-02-17 12:40

>>15
READABLE PERL CODE
Terrible!

Name: Anonymous 2011-02-17 12:44

Hands >>17 his glasses. You need them more than I do, son, if you can't read that.

Name: Anonymous 2011-02-17 12:51

>>18
I can read it too. That's the problem. the Perl Official Style Guidelines enforce putting seven logical lines inside an 80 characters long effective line, extensive use of $_, one character long varibles when they are strictly needed and expr while cond should be preferred to while cond expr.

Name: Anonymous 2011-02-17 14:17

>>19
Most of the time you don't even have to specify $_ because it will be defaulted to when no argument is given. I like that.

Name: Anonymous 2011-02-17 15:40

>>20
Using $_ implicitly was implicit in >>19.

Name: Anonymous 2011-02-17 16:35

telnet: connect to address 98.255.132.66: Connection refused

Name: Anonymous 2011-02-17 16:40

>>22
I took it down because nobody was using it. It's back up for now.

Name: Anonymous 2011-02-17 22:22

>>23
$ telnet 98.255.132.66 9099
Trying 98.255.132.66...
telnet: Unable to connect to remote host: Connection refused

HIBT?

Name: Anonymous 2011-02-17 22:33

>>24
YHBT

Name: Anonymous 2011-02-18 0:13

http://dis.4chan.org/read/prog/1196829427
Someone did this 3+ years ago, in Erlang.

Name: Anonymous 2011-02-18 0:15

>>23
Leave it up for 24/7/365!

Name: VIPPER 2011-02-18 3:29

It aint much use if its not 24 hours a day.
It would also help if it would show a greeting and how many people are one the chat and also a message when someone joins.

Name: Anonymous 2011-02-18 9:18

Needs more solutions.

Name: Anonymous 2011-02-18 12:09

>>28

#lang racket
(require racket/tcp
         (only-in srfi/43 vector-for-each))

(define clients (make-vector 255 #f)) ; fixed length vector because I'm evil.
(define listener (tcp-listen 9999))
(define users (make-parameter 0))

(struct client (id in out))

(define (broadcast message ignore-id)
  (vector-for-each
   (λ (cl)
     (unless (= ignore-id (client-id cl))
       (fprintf (client-out cl) "~a~n" message)))
   clients))

(define (add-client! in out)
  (with-handlers ((exn:fail:contract? (λ x (fprintf out "*** Exception: monadic pointer stack overflow~n")
                                        (close-output-port out) '|monadic pointer stack overflow|)))
    (let loop ((i 0))
      (if (vector-ref clients i) (loop (add1 i))
          (let ((cl (client i in out)))
            (users (add1 users))
            (vector-set! clients i cl) cl)))))

(define (delete-client! cl)
  (close-output-port (client-out cl))
  (users (sub1 users))
  (vector-set! clients (client-id cl) #f))

(let loop ()
  (let ((client (call-with-values (lambda () (tcp-accept listener)) add-client!)))
    (unless (eq? client '|monadic pointer stack overflow|)
      (fprintf (client-out client) "Hello!\r\nYou have successfully joined to the conversation,\r\n\
please remember to be respectful and polite by sageing your posts.\r\nThere are ~a people connected.\r\n" users)
      (broadcast "Someone joined.\r\n" (client-id client))
      (thread
       (lambda ()
         (let loop ((x (read-line (client-in client))))
           (cond ((or (eof-object? x)
                      (string-ci=? (substring x 0 5) "/quit"))
                  (broadcast "Someone quitted. :(((((\r\n" (client-id))
                  (delete-client! client))
                 ((string-ci=? (substring x 0 6) "/users")
                  (fprintf (client-out client) "There are ~a people connected.\r\n" users))
                 (else
                  (broadcast x (client-id client))
                  (loop (read-line (client-in client))))))))))
  (loop))

Name: Anonymous 2011-02-18 12:29

>>30
too lisp; didn't read

Name: Anonymous 2011-02-18 16:09

autist

Name: Anonymous 2011-02-18 16:10

<-- that's cool and all, but check 'em

Name: Anonymous 2011-02-18 19:21

RULE >>34 GET xD soooo randummmm lolololololololololololololololo

Name: Anonymous 2011-02-26 5:43

eh?

Name: Anonymous 2011-02-26 5:59

<----- epic rule36 get

Name: Anonymous 2011-11-27 2:46

Wonderful.. I will bookmark your blog and take the feeds also…I am satisfied to find so much useful info here in the post. Thank you for sharing. Vogue beautiful and popular dancing party full dress, you are worth owning.
http://www.hermeshandbagoutlet.com
http://www.handbagsdreams.com
http://www.backpackunion.com
http://www.charmhandbags.com
http://www.pursehandbag.org

Name: Anonymous 2011-11-27 5:08

it's down again


27 Name: Anonymous : 2011-02-18 00:15
>>23
Leave it up for 24/7/365!

28 Name: VIPPER : 2011-02-18 03:29
It aint much use if its not 24 hours a day.
It would also help if it would show a greeting and how many
people are one the chat and also a message when someone joins.

Name: VIPPER 2011-11-27 5:19

Someone should consider setting up a dedicated server for this.
Also why not use default port?

Name: Anonymous 2011-11-27 16:55

setting up a dedicated server for this.
like, rent a box somewhere? i could pay for it but i don't know how to take care of it... how would i give /prog/ access without fuckign shit up? thus, it will never come to pass.

Name: Anonymous 2011-11-28 7:18

import Network.Fancy
import Control.Concurrent
import Control.Monad
import Control.Exception
import System.IO

main = do hs <- newMVar []
          streamServer serverSpec { address = IPv4 "" 9099 } $ \h r ->
              modifyMVar_ hs (return . (h:))
              >> f r hs h `finally` modifyMVar_ hs (return . filter (/= h))
          sleepForever

f r hs h = do x <- hGetLine h
              putStrLn $ show r ++ " > " ++ x
              when (x /= "/quit") $ do
                  withMVar hs $ \hs' -> forM (filter (/= h) hs') $ \h' ->
                      hPutStrLn h' (show r ++ " > " ++ x) >> hFlush h'
                  f r hs h

Server at 50.56.35.147:9099, I'll leave it up like forever.

Name: Anonymous 2011-11-28 7:25

<!DOCTYPE html>
<html lang="en">
<head>
<title>nowjs test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script src="/nowjs/now.js"></script>

<script>
$(document).ready(function(){

  now.receiveMessage = function(name, message){
    $("#messages").append("<br>" + name + ": " + message);
  }

  $("#send-button").click(function(){
    now.distributeMessage($("#text-input").val());
    $("#text-input").val("");
  });

  now.name = prompt("What's your name?", "");

});
</script>
</head>

<body>
  <div id="messages"></div>
  <input type="text" id="text-input">
  <input type="button" value="Send" id="send-button">
</body>
</html>

Name: Anonymous 2011-11-28 7:44

>>41
Sorry, forgot where I was. Made it use nicks instead.
Also, again, 50.56.35.147 9099.

Name: Anonymous 2011-11-28 12:56

22, now with twice as many dubs

Name: Anonymous 2011-11-28 14:32

Don't use telnet you slobs, use netcat.

Name: Anonymous 2011-11-28 14:38

Don't send \r\ns you slobs, send \ns.

Name: Anonymous 2011-11-28 15:42

Name: Anonymous 2011-11-28 16:09

require'eventmachine';module C;@@c=[];def post_init;@@c<<self;send_data'Name: ';end;def receive_data x;@n?@@c.each{|c|c.send_data"<#@n> #{x}"}:@n=x.strip;end;end;(E=EventMachine)::run{E::start_server'localhost',6001,C}

Name: Anonymous 2011-11-28 17:44

>>47
That's not http, you fuckin' fucker cheeks patty!

Name: Anonymous 2013-09-01 21:04



   \            、____        /      /
     \          _ゝ、7´i-‐''7´ /    /
            ,.. -‐ ''"´ ̄  `"''ー' 、_     /
\       ,. '":::::::::::::::::::::::::::::::::::::::::::::`ヽ         /
  \       i::::::::ゝ:::_;:ゝ=== - 、、ィ:::::::::::::',       /
         / ''"´           `''、ヽ:::!   
\____)、____//´/  / ハ  i  ハ   i   ヽY \        /
        i / !  >'、/,_,| / | /_,!イ ハ ! |    ヽ、__人___,/(_
 ク.  こ   |' | /ヽ !__ レ' レ' ,.!-‐-、。oヽ!|    /i
 ソ.  の  ! ./レ'o '"´ ` ,     、、,,! !--─ァ ノ | 効 攻 あ
 チ  ク  \__.ハ""   ,. -‐‐ 、   ハ!-‐'i" r'_,.イ| か 撃 ん
 ン   .ソ  「 ___!,ヘ    i´     ',  / |_!_,ハノン_,,../ な .な .た
 チ  チ  |' !  i7>.、.,ヽ.    ノ,.イ| イ'´   `ヾ´./  い ん .ら
 ン  ン   | i,ヘ,.!-- 、ヘ`=r-=i´、::ヽ!/      Y`ヽ  の か の
 ! !  チ   |/    `ヽ、 \./ !::::ヽ_     'r____,i. よ
    ン   !       i::\}>o<{:::ヽ、__,,..-'" r-ノ  ! !
    ! !   ,>     /::::::::::::/::::::::::::::Y   _,ゝ'ヽ.  __
⌒y^ヽ.  ,へ(〉、,.-r-、ゝイ:::::::::/:::::::::i::::::::iVヽヘ「   )'´ `Y´`ヽ.
/   \!  /`     'ハ/::}>o<{:::::::::::l::::::::!     \
      ./     /ヘ:::::::/:::::::::::::::::::::::イゝ、_     \

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