Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Transcript del HolaMundo en Scala por ezamudio
//http://www.javamexico.org/blogs/ezamudio/holamundo_en_scala
import( java.io.* )
import( java.net.* )
hola.server {
HolaProc : Runnable {
HolaProc( input: InputStream, output: OutputStream ) {
input = BufferedReader( InputStreamReader( inputStream ) )
output = PrintStream( outputStream )
}
run() {
nombre = input.readLine()
output.printf("Hola, %s!%n", nombre )
output.flush()
}
}
HolaSocket : Runnable {
socket : Socket
HolaSocket( socket : Socket ) {
self.socket = socket
}
run() {
HolaProc( socket.getInputStream(), socket.getOutputStream() ).run()
socket.close()
}
}
Servidor {
port : Integer
sigue = true
Servidor( port : Integer ) {
self.port = port
}
stop() {
sigue = false
}
run() {
server = ServerSocket( port )
while({sigue},{
socket = server.accept()
out.println( "Nueva conexión" )
proc = HolaSocket( socket )
Thread( proc ).start()
})
}
}
}
@benek
Copy link

benek commented Jul 11, 2011

¿Objective-J?

@oscarryz
Copy link
Author

@benek Si, para aprovechar el syntax highlighting. Gist no te deja elegir un syntax highlighting y nombrar el archivo con una extensión diferente. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment