Skip to content

Instantly share code, notes, and snippets.

@noqisofon
Created November 11, 2010 03:35
Show Gist options
  • Save noqisofon/671954 to your computer and use it in GitHub Desktop.
Save noqisofon/671954 to your computer and use it in GitHub Desktop.
silicone(ryで書かれた、UDPSocket クラスを使ったデモその 2。
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