Created
November 11, 2010 03:35
-
-
Save noqisofon/671954 to your computer and use it in GitHub Desktop.
silicone(ryで書かれた、UDPSocket クラスを使ったデモその 2。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using std; | |
using std.io; | |
using std.text; | |
using net.socket; | |
let udp_receiver : UDPSocket = new UDPSocket( 11000 ); | |
let remote_endpoint : IPEndPoint = new IPEndPoint( IPAddress.ANY, 0 ); | |
try { | |
let received_bytes : byte[] = udp_receiver.receive( remote_endpoint ); | |
let result_text : string = Encoding.UTF_8.encodeFromBytes( received_bytes ); | |
console.puts( "this is the message you received ${result_text}" ); | |
console.puts( "this message was sent from ${remote_endpoint.address} on their port number ${remote_endpoint.port}" ) ); | |
} catch ( e : Exception ) { | |
console.puts( "${e}" ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment