codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
package; import sys.net.Socket; import sys.net.Host; class Server { static function main() { var s = new Socket(); s.bind(new Host("localhost"),5000); s.listen(1); trace("Starting server..."); while( true ) { var c:Socket = s.accept(); trace("Client connected..."); c.write("hello\n"); c.write("your IP is "+c.peer().host.toString()+"\n"); c.write("exit"); c.close(); } } } class Client { static function main() { var s = new Socket(); s.connect(new Host("localhost"),5000); while( true ) { var l = s.input.readLine(); trace(l); if( l == "exit" ) { s.close(); break; } } } }
Private
[
?
]
Run code
Submit