Update socket documentation
This commit is contained in:
parent
de15281ccb
commit
f51e9405c9
@ -278,10 +278,10 @@ if (isForwardRange!Range && isOrderingComparable!(ElementType!Range))
|
|||||||
* If the ranges have different lengths, they aren't equal.
|
* If the ranges have different lengths, they aren't equal.
|
||||||
*
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* R1 = First range type.
|
* R1 = First range type.
|
||||||
* R2 = Second range type.
|
* R2 = Second range type.
|
||||||
* range1 = First range.
|
* r1 = First range.
|
||||||
* range2 = Second range.
|
* r2 = Second range.
|
||||||
*
|
*
|
||||||
* Returns: $(D_KEYWORD true) if both ranges are equal, $(D_KEYWORD false)
|
* Returns: $(D_KEYWORD true) if both ranges are equal, $(D_KEYWORD false)
|
||||||
* otherwise.
|
* otherwise.
|
||||||
|
@ -13,50 +13,52 @@
|
|||||||
*
|
*
|
||||||
* class EchoProtocol : TransmissionControlProtocol
|
* class EchoProtocol : TransmissionControlProtocol
|
||||||
* {
|
* {
|
||||||
* private DuplexTransport transport;
|
* private DuplexTransport transport;
|
||||||
*
|
*
|
||||||
* void received(in ubyte[] data) @nogc
|
* void received(in ubyte[] data) @nogc
|
||||||
* {
|
* {
|
||||||
* transport.write(data);
|
* ubyte[512] buffer;
|
||||||
* }
|
* buffer[0 .. data.length] = data;
|
||||||
|
* transport.write(buffer[]);
|
||||||
|
* }
|
||||||
*
|
*
|
||||||
* void connected(DuplexTransport transport) @nogc
|
* void connected(DuplexTransport transport) @nogc
|
||||||
* {
|
* {
|
||||||
* this.transport = transport;
|
* this.transport = transport;
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* void disconnected(SocketException e) @nogc
|
* void disconnected(SocketException e) @nogc
|
||||||
* {
|
* {
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* void main()
|
* void main()
|
||||||
* {
|
* {
|
||||||
* auto address = defaultAllocator.make!InternetAddress("127.0.0.1", cast(ushort) 8192);
|
* auto address = defaultAllocator.make!InternetAddress("127.0.0.1", cast(ushort) 8192);
|
||||||
*
|
*
|
||||||
* version (Windows)
|
* version (Windows)
|
||||||
* {
|
* {
|
||||||
* auto sock = defaultAllocator.make!OverlappedStreamSocket(AddressFamily.inet);
|
* auto sock = defaultAllocator.make!OverlappedStreamSocket(AddressFamily.inet);
|
||||||
* }
|
* }
|
||||||
* else
|
* else
|
||||||
* {
|
* {
|
||||||
* auto sock = defaultAllocator.make!StreamSocket(AddressFamily.inet);
|
* auto sock = defaultAllocator.make!StreamSocket(AddressFamily.inet);
|
||||||
* sock.blocking = false;
|
* sock.blocking = false;
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* sock.bind(address);
|
* sock.bind(address);
|
||||||
* sock.listen(5);
|
* sock.listen(5);
|
||||||
*
|
*
|
||||||
* auto io = defaultAllocator.make!ConnectionWatcher(sock);
|
* auto io = defaultAllocator.make!ConnectionWatcher(sock);
|
||||||
* io.setProtocol!EchoProtocol;
|
* io.setProtocol!EchoProtocol;
|
||||||
*
|
*
|
||||||
* defaultLoop.start(io);
|
* defaultLoop.start(io);
|
||||||
* defaultLoop.run();
|
* defaultLoop.run();
|
||||||
*
|
*
|
||||||
* sock.shutdown();
|
* sock.shutdown();
|
||||||
* defaultAllocator.dispose(io);
|
* defaultAllocator.dispose(io);
|
||||||
* defaultAllocator.dispose(sock);
|
* defaultAllocator.dispose(sock);
|
||||||
* defaultAllocator.dispose(address);
|
* defaultAllocator.dispose(address);
|
||||||
* }
|
* }
|
||||||
* ---
|
* ---
|
||||||
*
|
*
|
||||||
|
@ -51,7 +51,7 @@ version (unittest)
|
|||||||
* T = Buffer type.
|
* T = Buffer type.
|
||||||
*/
|
*/
|
||||||
struct ReadBuffer(T = ubyte)
|
struct ReadBuffer(T = ubyte)
|
||||||
if (isScalarType!T)
|
if (isScalarType!T)
|
||||||
{
|
{
|
||||||
/// Internal buffer.
|
/// Internal buffer.
|
||||||
private T[] buffer_;
|
private T[] buffer_;
|
||||||
@ -66,16 +66,16 @@ struct ReadBuffer(T = ubyte)
|
|||||||
private size_t ring;
|
private size_t ring;
|
||||||
|
|
||||||
/// Available space.
|
/// Available space.
|
||||||
private immutable size_t minAvailable = 1024;
|
private size_t minAvailable = 1024;
|
||||||
|
|
||||||
/// Size by which the buffer will grow.
|
/// Size by which the buffer will grow.
|
||||||
private immutable size_t blockSize = 8192;
|
private size_t blockSize = 8192;
|
||||||
|
|
||||||
invariant
|
invariant
|
||||||
{
|
{
|
||||||
assert(length_ <= buffer_.length);
|
assert(this.length_ <= this.buffer_.length);
|
||||||
assert(blockSize > 0);
|
assert(this.blockSize > 0);
|
||||||
assert(minAvailable > 0);
|
assert(this.minAvailable > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,14 +89,14 @@ struct ReadBuffer(T = ubyte)
|
|||||||
* $(D_PSYMBOL free) < $(D_PARAM minAvailable)).
|
* $(D_PSYMBOL free) < $(D_PARAM minAvailable)).
|
||||||
* allocator = Allocator.
|
* allocator = Allocator.
|
||||||
*/
|
*/
|
||||||
this(in size_t size,
|
this(size_t size,
|
||||||
in size_t minAvailable = 1024,
|
size_t minAvailable = 1024,
|
||||||
shared Allocator allocator = defaultAllocator) @trusted
|
shared Allocator allocator = defaultAllocator) @trusted
|
||||||
{
|
{
|
||||||
this(allocator);
|
this(allocator);
|
||||||
this.minAvailable = minAvailable;
|
this.minAvailable = minAvailable;
|
||||||
this.blockSize = size;
|
this.blockSize = size;
|
||||||
buffer_ = cast(T[]) allocator_.allocate(size * T.sizeof);
|
this.buffer_ = cast(T[]) allocator_.allocate(size * T.sizeof);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ditto
|
/// ditto
|
||||||
@ -115,7 +115,7 @@ struct ReadBuffer(T = ubyte)
|
|||||||
*/
|
*/
|
||||||
~this() @trusted
|
~this() @trusted
|
||||||
{
|
{
|
||||||
allocator.deallocate(buffer_);
|
allocator.deallocate(this.buffer_);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -131,7 +131,7 @@ struct ReadBuffer(T = ubyte)
|
|||||||
*/
|
*/
|
||||||
@property size_t capacity() const
|
@property size_t capacity() const
|
||||||
{
|
{
|
||||||
return buffer_.length;
|
return this.buffer_.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,7 +139,7 @@ struct ReadBuffer(T = ubyte)
|
|||||||
*/
|
*/
|
||||||
@property size_t length() const
|
@property size_t length() const
|
||||||
{
|
{
|
||||||
return length_ - start;
|
return this.length_ - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ditto
|
/// ditto
|
||||||
@ -152,7 +152,7 @@ struct ReadBuffer(T = ubyte)
|
|||||||
*/
|
*/
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
start = length_ = ring;
|
start = this.length_ = ring;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -187,10 +187,10 @@ struct ReadBuffer(T = ubyte)
|
|||||||
*
|
*
|
||||||
* Returns: $(D_KEYWORD this).
|
* Returns: $(D_KEYWORD this).
|
||||||
*/
|
*/
|
||||||
ref ReadBuffer opOpAssign(string op)(in size_t length)
|
ref ReadBuffer opOpAssign(string op)(size_t length)
|
||||||
if (op == "+")
|
if (op == "+")
|
||||||
{
|
{
|
||||||
length_ += length;
|
this.length_ += length;
|
||||||
ring = start;
|
ring = start;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -234,9 +234,9 @@ struct ReadBuffer(T = ubyte)
|
|||||||
*
|
*
|
||||||
* Returns: Array between $(D_PARAM start) and $(D_PARAM end).
|
* Returns: Array between $(D_PARAM start) and $(D_PARAM end).
|
||||||
*/
|
*/
|
||||||
T[] opSlice(in size_t start, in size_t end)
|
T[] opSlice(size_t start, size_t end)
|
||||||
{
|
{
|
||||||
return buffer_[this.start + start .. this.start + end];
|
return this.buffer_[this.start + start .. this.start + end];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -250,23 +250,24 @@ struct ReadBuffer(T = ubyte)
|
|||||||
{
|
{
|
||||||
if (start > 0)
|
if (start > 0)
|
||||||
{
|
{
|
||||||
auto ret = buffer_[0 .. start];
|
auto ret = this.buffer_[0 .. start];
|
||||||
ring = 0;
|
ring = 0;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (capacity - length < minAvailable)
|
if (capacity - length < this.minAvailable)
|
||||||
{
|
{
|
||||||
void[] buf = buffer_;
|
void[] buf = this.buffer_;
|
||||||
immutable cap = capacity;
|
const cap = capacity;
|
||||||
() @trusted {
|
() @trusted {
|
||||||
allocator.reallocate(buf, (cap + blockSize) * T.sizeof);
|
allocator.reallocate(buf,
|
||||||
buffer_ = cast(T[]) buf;
|
(cap + this.blockSize) * T.sizeof);
|
||||||
|
this.buffer_ = cast(T[]) buf;
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
ring = length_;
|
ring = this.length_;
|
||||||
return buffer_[length_ .. $];
|
return this.buffer_[this.length_ .. $];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +311,7 @@ struct ReadBuffer(T = ubyte)
|
|||||||
* T = Buffer type.
|
* T = Buffer type.
|
||||||
*/
|
*/
|
||||||
struct WriteBuffer(T = ubyte)
|
struct WriteBuffer(T = ubyte)
|
||||||
if (isScalarType!T)
|
if (isScalarType!T)
|
||||||
{
|
{
|
||||||
/// Internal buffer.
|
/// Internal buffer.
|
||||||
private T[] buffer_;
|
private T[] buffer_;
|
||||||
@ -322,16 +323,16 @@ struct WriteBuffer(T = ubyte)
|
|||||||
private size_t ring;
|
private size_t ring;
|
||||||
|
|
||||||
/// Size by which the buffer will grow.
|
/// Size by which the buffer will grow.
|
||||||
private immutable size_t blockSize;
|
private const size_t blockSize;
|
||||||
|
|
||||||
/// The position of the free area in the buffer.
|
/// The position of the free area in the buffer.
|
||||||
private size_t position;
|
private size_t position;
|
||||||
|
|
||||||
invariant
|
invariant
|
||||||
{
|
{
|
||||||
assert(blockSize > 0);
|
assert(this.blockSize > 0);
|
||||||
// Position can refer to an element outside the buffer if the buffer is full.
|
// Position can refer to an element outside the buffer if the buffer is full.
|
||||||
assert(position <= buffer_.length);
|
assert(this.position <= this.buffer_.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -342,7 +343,7 @@ struct WriteBuffer(T = ubyte)
|
|||||||
*
|
*
|
||||||
* Precondition: $(D_INLINECODE size > 0 && allocator !is null)
|
* Precondition: $(D_INLINECODE size > 0 && allocator !is null)
|
||||||
*/
|
*/
|
||||||
this(in size_t size, shared Allocator allocator = defaultAllocator) @trusted
|
this(size_t size, shared Allocator allocator = defaultAllocator) @trusted
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(size > 0);
|
assert(size > 0);
|
||||||
@ -350,10 +351,10 @@ struct WriteBuffer(T = ubyte)
|
|||||||
}
|
}
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
blockSize = size;
|
this.blockSize = size;
|
||||||
ring = size - 1;
|
ring = size - 1;
|
||||||
allocator_ = allocator;
|
allocator_ = allocator;
|
||||||
buffer_ = cast(T[]) allocator_.allocate(size * T.sizeof);
|
this.buffer_ = cast(T[]) allocator_.allocate(size * T.sizeof);
|
||||||
}
|
}
|
||||||
|
|
||||||
@disable this();
|
@disable this();
|
||||||
@ -363,7 +364,7 @@ struct WriteBuffer(T = ubyte)
|
|||||||
*/
|
*/
|
||||||
~this()
|
~this()
|
||||||
{
|
{
|
||||||
allocator.deallocate(buffer_);
|
allocator.deallocate(this.buffer_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -371,7 +372,7 @@ struct WriteBuffer(T = ubyte)
|
|||||||
*/
|
*/
|
||||||
@property size_t capacity() const
|
@property size_t capacity() const
|
||||||
{
|
{
|
||||||
return buffer_.length;
|
return this.buffer_.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -384,13 +385,13 @@ struct WriteBuffer(T = ubyte)
|
|||||||
*/
|
*/
|
||||||
@property size_t length() const
|
@property size_t length() const
|
||||||
{
|
{
|
||||||
if (position > ring || position < start) // Buffer overflowed
|
if (this.position > ring || this.position < start) // Buffer overflowed
|
||||||
{
|
{
|
||||||
return ring - start + 1;
|
return ring - start + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return position - start;
|
return this.position - start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,61 +434,62 @@ struct WriteBuffer(T = ubyte)
|
|||||||
* Params:
|
* Params:
|
||||||
* buffer = Buffer chunk got with $(D_PSYMBOL opIndex).
|
* buffer = Buffer chunk got with $(D_PSYMBOL opIndex).
|
||||||
*/
|
*/
|
||||||
ref WriteBuffer opOpAssign(string op)(in T[] buffer)
|
ref WriteBuffer opOpAssign(string op)(const T[] buffer)
|
||||||
if (op == "~")
|
if (op == "~")
|
||||||
{
|
{
|
||||||
size_t end, start;
|
size_t end, start;
|
||||||
|
|
||||||
if (position >= this.start && position <= ring)
|
if (this.position >= this.start && this.position <= ring)
|
||||||
{
|
{
|
||||||
auto afterRing = ring + 1;
|
auto afterRing = ring + 1;
|
||||||
|
|
||||||
end = position + buffer.length;
|
end = this.position + buffer.length;
|
||||||
if (end > afterRing)
|
if (end > afterRing)
|
||||||
{
|
{
|
||||||
end = afterRing;
|
end = afterRing;
|
||||||
}
|
}
|
||||||
start = end - position;
|
start = end - this.position;
|
||||||
buffer_[position .. end] = buffer[0 .. start];
|
this.buffer_[this.position .. end] = buffer[0 .. start];
|
||||||
if (end == afterRing)
|
if (end == afterRing)
|
||||||
{
|
{
|
||||||
position = this.start == 0 ? afterRing : 0;
|
this.position = this.start == 0 ? afterRing : 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
position = end;
|
this.position = end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we have some free space at the beginning
|
// Check if we have some free space at the beginning
|
||||||
if (start < buffer.length && position < this.start)
|
if (start < buffer.length && this.position < this.start)
|
||||||
{
|
{
|
||||||
end = position + buffer.length - start;
|
end = this.position + buffer.length - start;
|
||||||
if (end > this.start)
|
if (end > this.start)
|
||||||
{
|
{
|
||||||
end = this.start;
|
end = this.start;
|
||||||
}
|
}
|
||||||
auto areaEnd = end - position + start;
|
auto areaEnd = end - this.position + start;
|
||||||
buffer_[position .. end] = buffer[start .. areaEnd];
|
this.buffer_[this.position .. end] = buffer[start .. areaEnd];
|
||||||
position = end == this.start ? ring + 1 : end - position;
|
this.position = end == this.start ? ring + 1 : end - this.position;
|
||||||
start = areaEnd;
|
start = areaEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
// And if we still haven't found any place, save the rest in the overflow area
|
// And if we still haven't found any place, save the rest in the overflow area
|
||||||
if (start < buffer.length)
|
if (start < buffer.length)
|
||||||
{
|
{
|
||||||
end = position + buffer.length - start;
|
end = this.position + buffer.length - start;
|
||||||
if (end > capacity)
|
if (end > capacity)
|
||||||
{
|
{
|
||||||
auto newSize = (end / blockSize * blockSize + blockSize) * T.sizeof;
|
const newSize = end / this.blockSize * this.blockSize
|
||||||
|
+ this.blockSize;
|
||||||
() @trusted {
|
() @trusted {
|
||||||
void[] buf = buffer_;
|
void[] buf = this.buffer_;
|
||||||
allocator.reallocate(buf, newSize);
|
allocator.reallocate(buf, newSize * T.sizeof);
|
||||||
buffer_ = cast(T[]) buf;
|
this.buffer_ = cast(T[]) buf;
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
buffer_[position .. end] = buffer[start .. $];
|
this.buffer_[this.position .. end] = buffer[start .. $];
|
||||||
position = end;
|
this.position = end;
|
||||||
if (this.start == 0)
|
if (this.start == 0)
|
||||||
{
|
{
|
||||||
ring = capacity - 1;
|
ring = capacity - 1;
|
||||||
@ -506,7 +508,7 @@ struct WriteBuffer(T = ubyte)
|
|||||||
*
|
*
|
||||||
* Returns: $(D_KEYWORD this).
|
* Returns: $(D_KEYWORD this).
|
||||||
*/
|
*/
|
||||||
ref WriteBuffer opOpAssign(string op)(in size_t length)
|
ref WriteBuffer opOpAssign(string op)(size_t length)
|
||||||
if (op == "+")
|
if (op == "+")
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@ -521,42 +523,42 @@ struct WriteBuffer(T = ubyte)
|
|||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
else if (position <= afterRing)
|
else if (this.position <= afterRing)
|
||||||
{
|
{
|
||||||
start += length;
|
start += length;
|
||||||
if (start > 0 && position == afterRing)
|
if (start > 0 && this.position == afterRing)
|
||||||
{
|
{
|
||||||
position = oldStart;
|
this.position = oldStart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto overflow = position - afterRing;
|
auto overflow = this.position - afterRing;
|
||||||
|
|
||||||
if (overflow > length)
|
if (overflow > length)
|
||||||
{
|
{
|
||||||
immutable afterLength = afterRing + length;
|
const afterLength = afterRing + length;
|
||||||
buffer_[start .. start + length] = buffer_[afterRing .. afterLength];
|
this.buffer_[start .. start + length] = this.buffer_[afterRing .. afterLength];
|
||||||
buffer_[afterRing .. afterLength] = buffer_[afterLength .. position];
|
this.buffer_[afterRing .. afterLength] = this.buffer_[afterLength .. this.position];
|
||||||
position -= length;
|
this.position -= length;
|
||||||
}
|
}
|
||||||
else if (overflow == length)
|
else if (overflow == length)
|
||||||
{
|
{
|
||||||
buffer_[start .. start + overflow] = buffer_[afterRing .. position];
|
this.buffer_[start .. start + overflow] = this.buffer_[afterRing .. this.position];
|
||||||
position -= overflow;
|
this.position -= overflow;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buffer_[start .. start + overflow] = buffer_[afterRing .. position];
|
this.buffer_[start .. start + overflow] = this.buffer_[afterRing .. this.position];
|
||||||
position = overflow;
|
this.position = overflow;
|
||||||
}
|
}
|
||||||
start += length;
|
start += length;
|
||||||
|
|
||||||
if (start == position)
|
if (start == this.position)
|
||||||
{
|
{
|
||||||
if (position != afterRing)
|
if (this.position != afterRing)
|
||||||
{
|
{
|
||||||
position = 0;
|
this.position = 0;
|
||||||
}
|
}
|
||||||
start = 0;
|
start = 0;
|
||||||
ring = capacity - 1;
|
ring = capacity - 1;
|
||||||
@ -596,15 +598,15 @@ struct WriteBuffer(T = ubyte)
|
|||||||
*
|
*
|
||||||
* Returns: A chunk of data buffer.
|
* Returns: A chunk of data buffer.
|
||||||
*/
|
*/
|
||||||
T[] opSlice(in size_t start, in size_t end)
|
T[] opSlice(size_t start, size_t end)
|
||||||
{
|
{
|
||||||
if (position > ring || position < start) // Buffer overflowed
|
if (this.position > ring || this.position < start) // Buffer overflowed
|
||||||
{
|
{
|
||||||
return buffer_[this.start .. ring + 1 - length + end];
|
return this.buffer_[this.start .. ring + 1 - length + end];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return buffer_[this.start .. this.start + end];
|
return this.buffer_[this.start .. this.start + end];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
/**
|
/**
|
||||||
* This module provides functions for converting between different types.
|
* This module provides functions for converting between different types.
|
||||||
*
|
*
|
||||||
* Copyright: Eugene Wissner 2017.
|
* Copyright: Eugene Wissner 2017-2018.
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||||
* Mozilla Public License, v. 2.0).
|
* Mozilla Public License, v. 2.0).
|
||||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
/**
|
/**
|
||||||
* Common exceptions and errors.
|
* Common exceptions and errors.
|
||||||
*
|
*
|
||||||
* Copyright: Eugene Wissner 2017.
|
* Copyright: Eugene Wissner 2017-2018.
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||||
* Mozilla Public License, v. 2.0).
|
* Mozilla Public License, v. 2.0).
|
||||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This package contains formatting and conversion functions.
|
* This package doesn't yet contain public symbols. Refer to
|
||||||
|
* $(D_PSYMBOL tanya.conv) for basic formatting and conversion functionality.
|
||||||
*
|
*
|
||||||
* Copyright: Eugene Wissner 2017.
|
* Copyright: Eugene Wissner 2017-2018.
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||||
* Mozilla Public License, v. 2.0).
|
* Mozilla Public License, v. 2.0).
|
||||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||||
|
@ -38,7 +38,7 @@ enum IEEEPrecision : ubyte
|
|||||||
/**
|
/**
|
||||||
* Tests the precision of floating-point type $(D_PARAM F).
|
* Tests the precision of floating-point type $(D_PARAM F).
|
||||||
*
|
*
|
||||||
* For $(D_KEYWORD float), $(D_PSYMBOL ieeePrecision) always evaluates to
|
* For $(D_KEYWORD float) $(D_PSYMBOL ieeePrecision) always evaluates to
|
||||||
* $(D_INLINECODE IEEEPrecision.single); for $(D_KEYWORD double) - to
|
* $(D_INLINECODE IEEEPrecision.single); for $(D_KEYWORD double) - to
|
||||||
* $(D_INLINECODE IEEEPrecision.double). It returns different values only
|
* $(D_INLINECODE IEEEPrecision.double). It returns different values only
|
||||||
* for $(D_KEYWORD real), since $(D_KEYWORD real) is a platform-dependent type.
|
* for $(D_KEYWORD real), since $(D_KEYWORD real) is a platform-dependent type.
|
||||||
@ -396,7 +396,7 @@ if (isFloatingPoint!F)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether $(D_PARAM x) is a denormilized number or not.
|
* Determines whether $(D_PARAM x) is a denormilized number or not.
|
||||||
|
*
|
||||||
* Denormalized number is a number between `0` and `1` that cannot be
|
* Denormalized number is a number between `0` and `1` that cannot be
|
||||||
* represented as
|
* represented as
|
||||||
*
|
*
|
||||||
@ -459,7 +459,7 @@ if (isFloatingPoint!F)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether $(D_PARAM x) is a normilized number or not.
|
* Determines whether $(D_PARAM x) is a normilized number or not.
|
||||||
|
*
|
||||||
* Normalized number is a number that can be represented as
|
* Normalized number is a number that can be represented as
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
/**
|
/**
|
||||||
* Network programming.
|
* Network programming.
|
||||||
*
|
*
|
||||||
* Copyright: Eugene Wissner 2016-2017.
|
* Copyright: Eugene Wissner 2016-2018.
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||||
* Mozilla Public License, v. 2.0).
|
* Mozilla Public License, v. 2.0).
|
||||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||||
|
@ -5,7 +5,43 @@
|
|||||||
/**
|
/**
|
||||||
* Low-level socket programming.
|
* Low-level socket programming.
|
||||||
*
|
*
|
||||||
* Copyright: Eugene Wissner 2016-2017.
|
* Current API supports only server-side TCP communication.
|
||||||
|
*
|
||||||
|
* Here is an example of a cross-platform blocking server:
|
||||||
|
*
|
||||||
|
* ---
|
||||||
|
* import std.stdio;
|
||||||
|
* import tanya.memory;
|
||||||
|
* import tanya.network;
|
||||||
|
*
|
||||||
|
* void main()
|
||||||
|
* {
|
||||||
|
* auto socket = defaultAllocator.make!StreamSocket(AddressFamily.inet);
|
||||||
|
* auto address = defaultAllocator.make!InternetAddress("127.0.0.1",
|
||||||
|
* cast(ushort) 8192);
|
||||||
|
*
|
||||||
|
* socket.setOption(SocketOptionLevel.SOCKET, SocketOption.REUSEADDR, true);
|
||||||
|
* socket.blocking = true;
|
||||||
|
* socket.bind(address);
|
||||||
|
* socket.listen(5);
|
||||||
|
*
|
||||||
|
* auto client = socket.accept();
|
||||||
|
* client.send(cast(const(ubyte)[]) "Test\n");
|
||||||
|
*
|
||||||
|
* ubyte[100] buf;
|
||||||
|
* auto response = client.receive(buf[]);
|
||||||
|
*
|
||||||
|
* writeln(cast(const(char)[]) buf[0 .. response]);
|
||||||
|
*
|
||||||
|
* defaultAllocator.dispose(client);
|
||||||
|
* defaultAllocator.dispose(socket);
|
||||||
|
* }
|
||||||
|
* ---
|
||||||
|
*
|
||||||
|
* For an example of an asynchronous server refer to the documentation of the
|
||||||
|
* $(D_PSYMBOL tanya.async.loop) module.
|
||||||
|
*
|
||||||
|
* Copyright: Eugene Wissner 2016-2018.
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||||
* Mozilla Public License, v. 2.0).
|
* Mozilla Public License, v. 2.0).
|
||||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* This package provides platform-independent interfaces to operating system
|
* This package provides platform-independent interfaces to operating system
|
||||||
* functionality.
|
* functionality.
|
||||||
*
|
*
|
||||||
* Copyright: Eugene Wissner 2017.
|
* Copyright: Eugene Wissner 2017-2018.
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||||
* Mozilla Public License, v. 2.0).
|
* Mozilla Public License, v. 2.0).
|
||||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* defined here.
|
* defined here.
|
||||||
* Also aliases for specific types like $(D_PSYMBOL SOCKET) are defined here.
|
* Also aliases for specific types like $(D_PSYMBOL SOCKET) are defined here.
|
||||||
*
|
*
|
||||||
* Copyright: Eugene Wissner 2017.
|
* Copyright: Eugene Wissner 2017-2018.
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||||
* Mozilla Public License, v. 2.0).
|
* Mozilla Public License, v. 2.0).
|
||||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||||
@ -58,4 +58,4 @@ align(1) struct GUID
|
|||||||
ushort Data2;
|
ushort Data2;
|
||||||
ushort Data3;
|
ushort Data3;
|
||||||
char[8] Data4;
|
char[8] Data4;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright: Eugene Wissner 2017.
|
* Copyright: Eugene Wissner 2017-2018.
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||||
* Mozilla Public License, v. 2.0).
|
* Mozilla Public License, v. 2.0).
|
||||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright: Eugene Wissner 2017.
|
* Copyright: Eugene Wissner 2017-2018.
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||||
* Mozilla Public License, v. 2.0).
|
* Mozilla Public License, v. 2.0).
|
||||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||||
@ -17,4 +17,4 @@ version (Windows):
|
|||||||
public import tanya.sys.windows.def;
|
public import tanya.sys.windows.def;
|
||||||
public import tanya.sys.windows.error;
|
public import tanya.sys.windows.error;
|
||||||
public import tanya.sys.windows.winbase;
|
public import tanya.sys.windows.winbase;
|
||||||
public import tanya.sys.windows.winsock2;
|
public import tanya.sys.windows.winsock2;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
/**
|
/**
|
||||||
* Definitions from winbase.h.
|
* Definitions from winbase.h.
|
||||||
*
|
*
|
||||||
* Copyright: Eugene Wissner 2017.
|
* Copyright: Eugene Wissner 2017-2018.
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||||
* Mozilla Public License, v. 2.0).
|
* Mozilla Public License, v. 2.0).
|
||||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||||
@ -52,4 +52,4 @@ extern(Windows)
|
|||||||
BOOL GetOverlappedResult(HANDLE hFile,
|
BOOL GetOverlappedResult(HANDLE hFile,
|
||||||
OVERLAPPED* lpOverlapped,
|
OVERLAPPED* lpOverlapped,
|
||||||
DWORD* lpNumberOfBytesTransferred,
|
DWORD* lpNumberOfBytesTransferred,
|
||||||
BOOL bWait) nothrow @system @nogc;
|
BOOL bWait) nothrow @system @nogc;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
/**
|
/**
|
||||||
* Definitions from winsock2.h, ws2def.h and MSWSock.h.
|
* Definitions from winsock2.h, ws2def.h and MSWSock.h.
|
||||||
*
|
*
|
||||||
* Copyright: Eugene Wissner 2017.
|
* Copyright: Eugene Wissner 2017-2018.
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||||
* Mozilla Public License, v. 2.0).
|
* Mozilla Public License, v. 2.0).
|
||||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||||
@ -216,4 +216,4 @@ enum
|
|||||||
SO_UPDATE_ACCEPT_CONTEXT = 0x700B,
|
SO_UPDATE_ACCEPT_CONTEXT = 0x700B,
|
||||||
SO_CONNECT_TIME = 0x700C,
|
SO_CONNECT_TIME = 0x700C,
|
||||||
SO_UPDATE_CONNECT_CONTEXT = 0x7010,
|
SO_UPDATE_CONNECT_CONTEXT = 0x7010,
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* The functions can cause segmentation fault if the module is compiled
|
* The functions can cause segmentation fault if the module is compiled
|
||||||
* in production mode and the condition fails.
|
* in production mode and the condition fails.
|
||||||
*
|
*
|
||||||
* Copyright: Eugene Wissner 2017.
|
* Copyright: Eugene Wissner 2017-2018.
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||||
* Mozilla Public License, v. 2.0).
|
* Mozilla Public License, v. 2.0).
|
||||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
/**
|
/**
|
||||||
* Test suite for $(D_KEYWORD unittest)-blocks.
|
* Test suite for $(D_KEYWORD unittest)-blocks.
|
||||||
*
|
*
|
||||||
* Copyright: Eugene Wissner 2017.
|
* Copyright: Eugene Wissner 2017-2018.
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||||
* Mozilla Public License, v. 2.0).
|
* Mozilla Public License, v. 2.0).
|
||||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||||
|
Loading…
Reference in New Issue
Block a user