このクライアントが LAN ネットワーク経由でサーバーに接続されている場合、クライアントの IP アドレスを取得し、テキスト ボックスに文字列として表示するにはどうすればよいですか? サーバーコード:
Imports System.Net.Sockets
Imports System.Threading
Imports System.Windows.Forms
Imports System.IO
Public Class broadcast
Private thread As Thread
Private listener As New TcpListener(5234)
Private writers As New ArrayList
Private name As String
Public Sub New(ByVal name As String)
MyBase.New()
Me.name = name
End Sub
Public Sub start()
listener.Start()
thread = New Thread(AddressOf RunServer)
thread.Start()
End Sub
Public Sub RunServer()
Try
While True
Dim writer As New BinaryWriter(New NetworkStream(listener.AcceptSocket))
writer.Write(name)
writers.Add(writer)
End While
Catch exception As Exception
'MessageBox.Show("Server application Closing")
End Try
End Sub
Public Sub sendCommand(ByVal command As String)
For i As Integer = 0 To writers.Count
Try
Dim writer As BinaryWriter
writer = CType(writers.Item(i), BinaryWriter)
writer.Write(command)
writer.Flush()
Catch inputputputexception As Exception
End Try
Next
End Sub
Public Sub stopAll()
For i As Integer = 0 To writers.Count
Try
Dim writer As BinaryWriter
writer = CType(writers.Item(0), BinaryWriter)
writer.Close()
writers.Remove(0)
Catch inputputputexception As Exception
End Try
Next
listener.Stop()
End Sub
クラス終了