On Friday, 14 August 2015 at 14:12:14 UTC, Alex Parrill wrote:
On Friday, 14 August 2015 at 14:06:03 UTC, Kingsley wrote:
Hi
Does anyone have some examples of making a client socket
connection to a host on a port and parsing the incoming data
in some kind of loop.
--K
auto addresses = getAddress("localhost", 8085);
auto socket = new Socket(AddressFamily.INET,
SocketType.STREAM, ProtocolType.TCP);
scope(exit) socket.close();
socket.connect(addresses[0]);
auto buffer = new ubyte[2056];
ptrdiff_t amountRead;
while((amountRead = socket.receive(buffer)) != 0) {
enforce(amountRead > 0, lastSocketError);
// Do stuff with buffer
}
Great thanks.
How would I send stuff back to the server without blocking? Is
there some kind of IO reactor / event machine library for D that
could help me?