Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i use std.socket and std.socketstream? (D programming language 2.x)

i was wondering how to use those phobos modules to use networking?

Or you can give a reference to how to use sockets (in a way similar or almost similar to D)

like image 939
zaphnat Avatar asked Apr 24 '09 20:04

zaphnat


2 Answers

from memory

auto MyStream = new SocketStream(new Socket(new TcpAddress("stakoverflow.com", 80)));
like image 94
BCS Avatar answered Oct 17 '22 07:10

BCS


std.socket.Socket is essentially a semi-thin wrapper around your operating system's native socket functions. For that reason, I recommend understanding the basics of socket programming in C first - there are plenty of examples for that - then, the std.socket API should be trivial.

For reference: http://digitalmars.com/d/2.0/phobos/std_socket.html

like image 36
FeepingCreature Avatar answered Oct 17 '22 06:10

FeepingCreature