VB NET Client Server App Guide
VB NET Client Server App Guide
This guide provides step-by-step instructions and VB.NET code to create a simple client-server
application. The client sends a request to the server, and the server simulates a key press upon
1. Open Visual Studio and create a new Console App (.NET Framework) project.
2. Copy and paste the following code into the Module1.vb file.
3. Run the server application. It will listen on port 5000 for incoming client requests.
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Imports System.Threading
Module ServerApp
Sub Main()
listener.Start()
While True
thread.Start(client)
End While
End Sub
Try
SimulateKeyPress("A")
End If
stream.Write(response, 0, response.Length)
client.Close()
Catch ex As Exception
Console.WriteLine($"Error: {ex.Message}")
End Try
End Sub
My.Computer.Keyboard.SendKeys(key)
End Sub
End Module
1. Open Visual Studio and create a new Windows Forms App (.NET Framework) project.
3. Copy and paste the following code into the Form1.vb file.
4. Run the client application and click the button to send a request to the server.
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
btnSendRequest.Click
Try
stream.Write(message, 0, message.Length)
End Using
Catch ex As Exception
End Try
End Sub
End Class