How to send messages from one computer to another using vb.net?

Ok, so I wanted to do this for several years, and it amazes me that no one can come up with a solution ... I want to write a program (preferably on vb.net) that can send a message to another computer (or device), which connected to the same network as me. I want the message to appear on another computer (or device) in the message popup. In addition, it would be ideal if this could be done through some kind of Bluetooth connection, if not then a local ip connection will occur. I don’t know how I would do it, but I know that it’s possible because I saw some programs doing this ... in fact, I saw a blackrain program that can display without any additional software installed messages on the ipod touch screen to instruct yser what to do and then display the results from their input on the computer screen almost instantly. I would like to know how this works, if anyone has thoughts, feel free to share them!

Additional Information:

  • I have a lot of experience with vb.net, command line functions and vbscript.

  • I am currently running Windows 7 Professional x64

  • I have an external bluetooth bluetooth adapter.

  • I would like it to be (if possible) similar to those ipod / iphone applications that allow you to control the laptop cursor over wifi sync; in the sense that installation is not required, and no additional software is required. (Example: remotepad.ipa)

The code for the message box will look something like this:

ObjClient = New TcpClient("127.0.0.1", 1000) TcpClient.Start() Messagebox.Show("Popup Message Here") TcpClient.Close() 

I know that this code will do the same on the command line:

 msg * /SERVER:localhost hello 

or this code will do the same on the command line:

 msg * hello > localhost 

But I want to do this without any batch files, if possible, because I do not want to configure anything on the other end.

Thanks!

Maybe this has something to do with sockets or ports?


+4
source share
1 answer

Using TcpClient and its associated libraries is definitely the correct answer.

Example code for writing data to a specific IP port:

 ''' <summary> ''' Send data over TCP/IP network ''' </summary> ''' <param name="data">Data string to write</param> ''' <param name="IP">The connected destination TcpClient</param> Public Sub WriteData(ByVal data As String, ByRef IP As String) Console.WriteLine("Sending message """ & data & """ to " & IP) Dim client As TcpClient = New TcpClient() client.Connect(New IPEndPoint(IPAddress.Parse(IP), My.Settings.CommPort)) Dim stream As NetworkStream = client.GetStream() Dim sendBytes As Byte() = Encoding.ASCII.GetBytes(data) stream.Write(sendBytes, 0, sendBytes.Length) End Sub 

Use TcpListener to view incoming data.

http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx

edit: in order to find out which IP address will send it ... You can either have a list of internal IP addresses for connection, or connect each network computer to your program if it is statically placed on a box. For my purposes, when I use this code, the host process is on a well-known server. Client processes that want to receive messages send a quick message to the host, which then records the IP address that they can send later.

Obtaining the IP address of the requesting client:

 ''Given variable m_listener is an active TcpListener... Dim client As TcpClient = m_listener.AcceptTcpClient() Dim requesterIP As String = client.Client.RemoteEndPoint.ToString().Split(New Char() {":"})(0) 
+2
source

Source: https://habr.com/ru/post/1369028/


All Articles