Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8947239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:42:23+00:00 2026-06-15T12:42:23+00:00

I have two applications running on different computers, one of them is a client

  • 0

I have two applications running on different computers, one of them is a client and the other one is a server, the communication on Client -> Server works perfectly, although it doesn’t on the opposite direction.

Server code:

Imports System.IO
Imports System.Net
Public Class Form1
    Dim listener as Net.Sockets.TcpListener
    Dim listenThread as Threading.Thread

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        listener = New Net.Sockets.TcpListener(Net.IPAddress.Any, 32111)
        listener.Start()
        listenThread = New Threading.Thread(AddressOf DoListen)
        listenThread.IsBackground = True
        listenThread.Start()
End Sub


Private Sub DoListen()
        Dim sr As IO.StreamReader
        Dim sw As IO.StreamWriter
        Do
            Try
                Dim client As Net.Sockets.TcpClient = listener.AcceptTcpClient
                sr = New IO.StreamReader(client.GetStream)
                sw = New IO.StreamWriter(client.GetStream)
                Dim Lines As String() = sr.ReadToEnd.Split(New Char() {","c}) 'get client data

                sr.Close()
                sw.Write("Message123") ' try to send data to client
                sw.Close()

            Catch
            End Try
        Loop
    End Sub
End Class

Client code:

Public Class Form1
    Dim Command As String
    Dim thread As Threading.Thread

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        thread = New Threading.Thread(AddressOf MyProcess)
        thread.IsBackground = True
        thread.Start()
    End Sub

Private Sub Send(ByVal Command As String)
        Try
            Dim client As New System.Net.Sockets.TcpClient
            client.Connect(TextBox1.Text, 32111)
            Dim writer As New IO.StreamWriter(client.GetStream)
            writer.Write(Command)
            writer.Flush()
            client.Close()
            MsgBox("Command has been sent successfully")
        Catch ex As Exception
        End Try
    End Sub

Private Sub MyProcess()
        Do
            Dim client As New System.Net.Sockets.TcpClient
            client.Connect("192.168.1.2", 32111)
            Dim reader As New IO.StreamReader(client.GetStream)
            MessageBox.Show(reader.ReadToEnd)
            reader.Close()
            client.Close()
        Loop
    End Sub
End Class

The thing is that nothing happens, the MessageBox doesn’t appear on the client saying “Message123”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:42:25+00:00Added an answer on June 15, 2026 at 12:42 pm

    Each time the client creates a new socket and connects to it, it opens an entirely new channel of communication between the two applications. In your example, the server is returning a message on the first socket, but on the client it does not try to read from the first socket. instead, it opens a second socket and reads from that. You need to change it so that you are reading from the same socket on which you sent the request message.

    If you think about it, you are making an assumption which can’t possibly be true. You are assuming that there can only be one valid socket from your client machine to the server on that port. However obviously this is not true. You can run many separate FTP clients and to the same server, for instance. Each application can open as many sockets to the same port on the same server as they want to, and they are all completely independent from each other.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have two different servers running our web application, one is Windows and other
I have written two different applications running as windows services. Each application represents one
I have two different web applications running on two different instances of tomcat. I
I have two web applications that are running on a single Tomcat server and
I have two different C# applications that are running at the same time. I
Assume you have two web applications running in two different tabs/windows in your browser.
I have two applications running on different domains: webformapp.com mvcapp.com webformapp.com has an iframe
I have two web applications, which I want to be running under the one
I have two cakephp2 applications running on same database, but having different Auth tables
I have two (same) applications running on dev.example.com and beta.example.com with different databases. Everything

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.