1 /* 2 * Archttp - A highly performant web framework written in D. 3 * 4 * Copyright (C) 2021-2022 Kerisy.com 5 * 6 * Website: https://www.kerisy.com 7 * 8 * Licensed under the Apache-2.0 License. 9 * 10 */ 11 12 module geario.net.channel.Types; 13 14 import geario.net.IoError; 15 import geario.util.queue.SimpleQueue; 16 import geario.Functions; 17 import geario.system.Memory; 18 import geario.logging; 19 20 import core.atomic; 21 import std.socket; 22 23 import nbuff; 24 25 alias DataSendedHandler = void delegate(ulong n); 26 alias DataReceivedHandler = void delegate(NbuffChunk bytes); 27 alias AcceptHandler = void delegate(Socket socket); 28 alias ErrorEventHandler = Action1!(IoError); 29 30 alias ConnectionHandler = void delegate(bool isSucceeded); 31 alias UdpDataHandler = void delegate(const(ubyte)[] data, Address addr); 32 33 34 /** 35 */ 36 interface Channel { 37 38 } 39 40 41 42 enum ChannelType : ubyte { 43 Accept = 0, 44 TCP, 45 UDP, 46 Timer, 47 Event, 48 File, 49 None 50 } 51 52 enum ChannelFlag : ushort { 53 None = 0, 54 Read, 55 Write, 56 57 OneShot = 8, 58 ETMode = 16 59 } 60 61 final class UdpDataObject { 62 Address addr; 63 ubyte[] data; 64 } 65 66 final class BaseTypeObject(T) { 67 T data; 68 } 69 70 71 72 // alias WritingBufferQueue = SimpleQueue!NbuffChunk; 73 74 /** 75 */ 76 Address CreateAddress(AddressFamily family = AddressFamily.INET, 77 ushort port = InternetAddress.PORT_ANY) { 78 if (family == AddressFamily.INET6) { 79 // addr = new Internet6Address(port); // bug on windows 80 return new Internet6Address("::", port); 81 } else 82 return new InternetAddress(port); 83 }