initial commit
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
Imports System
|
||||
Imports System.Diagnostics
|
||||
Imports System.Net.Sockets
|
||||
Imports System.Threading
|
||||
|
||||
Friend Class Relay
|
||||
|
||||
Private Shared thread As Threading.Thread
|
||||
Private Shared thread2 As Threading.Thread
|
||||
Public Sub method_0(tcpClient_2 As TcpClient, tcpClient_3 As TcpClient)
|
||||
|
||||
tcpClient_0 = tcpClient_2
|
||||
tcpClient_1 = tcpClient_3
|
||||
|
||||
networkStream_0 = tcpClient_2.GetStream()
|
||||
networkStream_1 = tcpClient_3.GetStream()
|
||||
|
||||
thread = New Thread(AddressOf method_1)
|
||||
thread2 = New Thread(AddressOf method_2)
|
||||
|
||||
thread.Start()
|
||||
thread2.Start()
|
||||
|
||||
End Sub
|
||||
Public Shared Sub Close()
|
||||
Try
|
||||
thread?.Abort()
|
||||
thread2?.Abort()
|
||||
Catch
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub method_1()
|
||||
Try
|
||||
Dim array As Byte() = New Byte(24576) {}
|
||||
While True
|
||||
Dim num As Integer = networkStream_0.Read(array, 0, array.Length)
|
||||
If num = 0 Then
|
||||
Exit While
|
||||
End If
|
||||
networkStream_1.Write(array, 0, num)
|
||||
networkStream_1.Flush()
|
||||
End While
|
||||
networkStream_0.Close()
|
||||
tcpClient_0.Close()
|
||||
tcpClient_1.Close()
|
||||
networkStream_1.Close()
|
||||
Catch ex As Exception
|
||||
tcpClient_0.Close()
|
||||
tcpClient_1.Close()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub method_2()
|
||||
Try
|
||||
Dim array As Byte() = New Byte(24576) {}
|
||||
While True
|
||||
Dim num As Integer = networkStream_1.Read(array, 0, array.Length)
|
||||
If num = 0 Then
|
||||
Exit While
|
||||
End If
|
||||
networkStream_0.Write(array, 0, num)
|
||||
networkStream_0.Flush()
|
||||
End While
|
||||
networkStream_0.Close()
|
||||
tcpClient_0.Close()
|
||||
tcpClient_1.Close()
|
||||
networkStream_1.Close()
|
||||
Catch ex As Exception
|
||||
tcpClient_0.Close()
|
||||
tcpClient_1.Close()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private tcpClient_0 As TcpClient
|
||||
|
||||
Private tcpClient_1 As TcpClient
|
||||
|
||||
Private networkStream_0 As NetworkStream
|
||||
|
||||
Private networkStream_1 As NetworkStream
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user