1 #Region "Microsoft.VisualBasic::a491bd98f891310b14cf4957ddae8936, Microsoft.VisualBasic.Core\Net\Abstract.vb"
2
3     ' Author:
4     
5     '       asuka (amethyst.asuka@gcmodeller.org)
6     '       xie (genetics@smrucc.org)
7     '       xieguigang (xie.guigang@live.com)
8     
9     ' Copyright (c) 2018 GPL3 Licensed
10     
11     
12     ' GNU GENERAL PUBLIC LICENSE (GPL3)
13     
14     
15     ' This program is free software: you can redistribute it and/or modify
16     ' it under the terms of the GNU General Public License as published by
17     ' the Free Software Foundation, either version 3 of the License, or
18     ' (at your option) any later version.
19     
20     ' This program is distributed in the hope that it will be useful,
21     ' but WITHOUT ANY WARRANTY; without even the implied warranty of
22     ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23     ' GNU General Public License for more details.
24     
25     ' You should have received a copy of the GNU General Public License
26     ' along with this program. If not, see <http://www.gnu.org/licenses/>.
27
28
29
30     ' /********************************************************************************/
31
32     ' Summaries:
33
34     '     Class IProtocolHandler
35     
36     
37     
38     '     Delegate Sub
39     
40     
41     '     Delegate Function
42     
43     
44     '     Interface IServicesSocket
45     
46     '         Properties: IsRunning, IsShutdown, LocalPort
47     
48     '         Function: (+2 Overloads) Run
49     
50     '     Interface IDataRequestHandler
51     
52     '         Properties: Responsehandler
53     
54     
55     
56     
57     
58     ' /********************************************************************************/
59
60 #End Region
61
62 Imports Microsoft.VisualBasic.ComponentModel
63 Imports Microsoft.VisualBasic.Net.Protocols
64 Imports Microsoft.VisualBasic.Net.Protocols.Reflection
65 Imports Microsoft.VisualBasic.Net.Tcp
66
67 Namespace Net.Abstract
68
69     ''' <summary>
70     ''' Object for handles the request <see cref="Protocol"/>.
71     ''' </summary>
72     Public MustInherit Class IProtocolHandler
73
74         MustOverride ReadOnly Property ProtocolEntry As Long
75         MustOverride Function HandleRequest(request As RequestStream, remoteDevcie As System.Net.IPEndPoint) As RequestStream
76     End Class
77
78 #Region "Delegate Abstract Interface"
79
80     Public Delegate Sub ForceCloseHandle(socket As StateObject)
81
82     ''' <summary>
83     ''' 
84     ''' </summary>
85     ''' <param name="request"></param>
86     ''' <param name="RemoteAddress"></param>
87     ''' <returns></returns>
88     Public Delegate Function DataRequestHandler(request As RequestStream, RemoteAddress As System.Net.IPEndPoint) As RequestStream
89 #End Region
90
91     ''' <summary>
92     ''' Socket listening object which is running at the server side asynchronous able multiple threading.
93     ''' (运行于服务器端上面的Socket监听对象,多线程模型)
94     ''' </summary>
95     ''' <remarks></remarks>
96     Public Interface IServicesSocket : Inherits IDisposable, ITaskDriver, IDataRequestHandler
97
98         ''' <summary>
99         ''' The server services listening on this local port.(当前的这个服务器对象实例所监听的本地端口号)
100         ''' </summary>
101         ''' <value></value>
102         ''' <returns></returns>
103         ''' <remarks></remarks>
104         ReadOnly Property LocalPort As Integer
105         ReadOnly Property IsShutdown As Boolean
106         ReadOnly Property IsRunning As Boolean
107
108         ''' <summary>
109         ''' This server waits for a connection and then uses  asychronous operations to
110         ''' accept the connection, get data from the connected client,
111         ''' echo that data back to the connected client.
112         ''' It then disconnects from the client and waits for another client.(请注意,当服务器的代码运行到这里之后,代码将被阻塞在这里)
113         ''' </summary>
114         ''' <remarks></remarks>
115         Overloads Function Run() As Integer
116
117         ''' <summary>
118         ''' This server waits for a connection and then uses  asychronous operations to
119         ''' accept the connection, get data from the connected client,
120         ''' echo that data back to the connected client.
121         ''' It then disconnects from the client and waits for another client.(请注意,当服务器的代码运行到这里之后,代码将被阻塞在这里)
122         ''' </summary>
123         ''' <remarks></remarks>
124         Overloads Function Run(localEndPoint As System.Net.IPEndPoint) As Integer
125     End Interface
126
127     Public Interface IDataRequestHandler
128
129         ''' <summary>
130         ''' This function pointer using for the data request handling of the data request from the client socket.
131         ''' (这个函数指针用于处理来自于客户端的请求)
132         ''' </summary>
133         ''' <remarks></remarks>
134         Property Responsehandler As DataRequestHandler
135     End Interface
136 End Namespace