RosettaCodeData/Task/Sockets/D/sockets.d

16 lines
429 B
D
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
module socket ;
import std.stdio ;
import std.socket ;
version(Win32) {
// For Win32 systems, need to link with ws2_32.lib.
pragma(lib, "ws2_32.lib") ;
}
void main() {
2016-12-05 22:15:40 +01:00
long res;
2013-04-11 01:07:29 -07:00
auto socket = new Socket(AddressFamily.INET, SocketType.STREAM) ;
socket.connect(new InternetAddress("localhost",256)) ;
2016-12-05 22:15:40 +01:00
res = socket.send(cast(void[])"hello socket world") ;
writefln("Socket %d bytes sent.", res) ;
2013-04-11 01:07:29 -07:00
socket.close() ;
}