Posts Tagged ‘vb 2005’

Whats up?

Posted: April 25, 2010 in General
Tags: , , , , , ,

I know i’ve been out for a while, but im not dead!  Ive moved all my home system over to the PLM system.  For a couple of reasons.  First the PLC SDM software is no longer supported.
And many times that my program has stopped has been a cause of this.  Its still a great device and Im not planning on removing any pages related to it.

Here is a link of a excellent site to get you started sending commands to the PLM.  Has all the basics and even sample code.  I moved all my custom code following this.

http://www.madreporite.com/insteon/insteon.html

So what have I been working on?
Would you believe decorations?. Im now stocking up on LampLincs for 2010.  I’m up to 30 now (This is of course not counting the one for the home). I’ve got myself a extra PLM off Ebay (2112) and another one on the way.  Even my first PLC will be used for the second phase of the home.  I’ll later go into detail, just that I wanted to show im still here. 🙂

For the 2112, go for the older ones, the new ones dont have a ‘pass-thru’ outlet. And this key to sending groups commands fast!  Hence why I ordered another one.

Also ive been stocking up on LED lights, as you may now the lamplincs have a max load of 300 watts, and with the average load of a traditional 100 bulbs string runs at around 46-64 watts you can add more lights on a single Lamplinc,  For example for this Christmas im suspecting I will need 3 Lamplincs for the icicles.

We’ll off, and thanks for all the comments, I see this blog gets hit a lot. Appreciate it!

Hi, so I know ive been disconnected for a while.  But always trying to provide some goodies.

One of the cool things of the PLC is that if you know serial commands you can actually talk to it bypassing the SDM software.  My reason being that X10 motion sensors are cheeper than the Insteon and smaller which I can hide in different places but I would run in to the problem of the x10 signals not making it back to my main computer.  So what If you can have something on another computer which can transalate it to Insteon ?:)

So what I was right on the back of the PLC I have a transceiver and use the PLC with this small code to convert it to Insteon.  This way I basically have a x10 receiver on the other leg of my home.

So below is a small little program I use to  ‘convert’ X10 signals to a Insteon signal.  In my case the PLC will sending a ON  or OFF command to the PLM and depending the rate is the house code for example (B5,B6).   For the example im using VB 2005.  2008 and 2010 will work fine as well.  Note that i am bypassing entirely the SDM software.  if you don’t call it in your code it wont load, but you do have the port locked and isn’t sharable  🙂

A very good starting point is this site and I basically started from here http://www.madreporite.com/insteon/insteon.html which will show you how read bytes, which is how the plc will respond as well.

Basically the PLC talks at 4800,8,N,1.  The program consist of a simple form with  just one button to exit.


Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Imports System.IO
Imports System.IO.Ports
Imports System.Net

Public Class Form1
 Public WithEvents PLC As New IO.Ports.SerialPort
 Public X10_House_Code As String
 Public X10_House_VALUE As Integer
 Public X10_Command As String
 Public PLC_Queue As String
 Public handler As New mySerialDelegate(AddressOf Process_Queue)  ' Once we read the data process it in a separate thread.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 '------ OPEN PLC SERIAL CONNECTION SETUP PLC AND LEAVE READY - 
 PLC.PortName = "COM1"
 PLC.BaudRate = 4800
 PLC.DataBits = 8
 PLC.Parity = Parity.None
 PLC.StopBits = StopBits.One
 If PLC.IsOpen = False Then PLC.Open()

End Sub

 '---- THIS IS THE EVENT THAT WILL FIRE EACH TIME DATA IS RECEIVED BASICALLY WE CAPTURE ALL THE DATA AND
 '---- CALL THE OTHER THEAD TO CONVERT IT.
 Private Sub PLC_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles PLC.DataReceived
 Dim A, Bytes_to_read As Integer
 Dim rcvBuf(4096) As Byte
 Bytes_to_read = PLC.BytesToRead
 Do While PLC.BytesToRead > 0
 PLC.Read(rcvBuf, 0, rcvBuf.Length)
 For A = 0 To Bytes_to_read - 1
 PLC_Queue = PLC_Queue + Hex(rcvBuf(A)).PadLeft(2, "0") + " "
 Next
 Bytes_to_read = PLC.BytesToRead

 Loop

 Me.BeginInvoke(handler)
 End Sub

 Public Delegate Sub mySerialDelegate()
 Public Sub Process_Queue()

 'CONVERT STEAM TO X10 HOUSE CODES and the VALUE THAT WILL BE PASS TO THE OTHER DEVICE
 ' SO WHEN IT SEEN B2 IT WILL SEND TO THE OTHER SIDE A VALUE OF 18 ON THE RATE OR 'ON' VALUE
 ' Im only converting the B Code nothing else. 

 If PLC_Queue.Contains("02 4A 00 EE ") Then X10_House_Code = "B2" : X10_House_VALUE = 18
 If PLC_Queue.Contains("02 4A 00 E2 ") Then X10_House_Code = "B3" : X10_House_VALUE = 19
 If PLC_Queue.Contains("02 4A 00 EA ") Then X10_House_Code = "B4" : X10_House_VALUE = 20
 If PLC_Queue.Contains("02 4A 00 E1 ") Then X10_House_Code = "B5" : X10_House_VALUE = 21
 If PLC_Queue.Contains("02 4A 00 E9 ") Then X10_House_Code = "B6" : X10_House_VALUE = 22
 If PLC_Queue.Contains("02 4A 00 E5 ") Then X10_House_Code = "B7" : X10_House_VALUE = 23
 If PLC_Queue.Contains("02 4A 00 E4 ") Then X10_House_Code = "B8" : X10_House_VALUE = 24
 If PLC_Queue.Contains("02 4A 00 E7 ") Then X10_House_Code = "B9" : X10_House_VALUE = 25
 If PLC_Queue.Contains("02 4A 00 EF ") Then X10_House_Code = "B10" : X10_House_VALUE = 26
 If PLC_Queue.Contains("02 4A 00 E3 ") Then X10_House_Code = "B11" : X10_House_VALUE = 27
 If PLC_Queue.Contains("02 4A 00 EB ") Then X10_House_Code = "B12" : X10_House_VALUE = 28
 If PLC_Queue.Contains("02 4A 00 E0 ") Then X10_House_Code = "B13" : X10_House_VALUE = 30
 If PLC_Queue.Contains("02 4A 00 E8 ") Then X10_House_Code = "B14" : X10_House_VALUE = 31
 If PLC_Queue.Contains("02 4A 00 E4 ") Then X10_House_Code = "B15" : X10_House_VALUE = 32
 If PLC_Queue.Contains("02 4A 00 EC ") Then X10_House_Code = "B16" : X10_House_VALUE = 32

 '- ON OR OFF
 If PLC_Queue.Contains("02 4A 01 E2 ") Then X10_Command = "ON" : Send_Bytes(X10_House_VALUE, True) : Debug.Print(X10_House_Code) : X10_House_Code = "" : X10_Command = ""
 If PLC_Queue.Contains("02 4A 01 E3 ") Then X10_Command = "OFF" : Send_Bytes(X10_House_VALUE, False) : Debug.Print(X10_House_Code) : X10_House_Code = "" : X10_Command = ""

 Debug.Print(PLC_Queue)

 ' Clear and start again
 PLC_Queue = ""
 End Sub

Public Function Send_Bytes(ByVal value As Integer, ByVal State As Boolean) As Boolean
 Dim RECEIVER() As String = Split("0D.FE.9E", ".")  '-- THIS CONTAINS WHO WE ARE SENDING THE MESSAGE TO CHANGE AS NECESSARY
 '-- MAGIC CODE TO SEND TO PLC (I'LL EXPLAIN THEM LATER)
 Dim xmtbuf() As Byte = {&H2, &H40, &H1, &HA1, &H0, &H9, &HFD, &HE4, &H0, &H0, &H0, &HD, &HB, &H44, &H5, &H11, &H1}

 '-- HERE WE WILL REPLACE THE BYTES ABOVE IN BOLD TO WANT TO SEND TO,
 xmtbuf(11) = System.Convert.ToInt32(RECEIVER(0), 16)
 xmtbuf(12) = System.Convert.ToInt32(RECEIVER(1), 16)
 xmtbuf(13) = System.Convert.ToInt32(RECEIVER(2), 16)

 '- DEPENDING ON THE DEVICE BEING ON OR OFF WE SWAP ONE OF THE BYTES
 If State = True Then xmtbuf(15) = 17 Else xmtbuf(15) = 19 ' If on then push 17 if off push 19

 '--- HERE WE INSERT THE VALUE / X10 HOUSE CODE WE HAVE PREDIFINED 
 xmtbuf(16) = value

 '--- CALL OUR LITTLE FUNCTION TO WRITE THE BYTES TO THE SERIAL PORT
 PLC_Write(xmtbuf)

 '--- SETUP SOME MORE BYTES (THIS DOENST CHANGE) AND WRITE THEM, THIS TELLS THE PLC TO PROCESS THE BYTES WE SENT
 '--- BEFORE
 Dim xmtBuf2() As Byte = {&H2, &H46, &H1, &H42, &H10, &H9F}
 PLC_Write(xmtBuf2)
 End Function

 '--- THIS FUNCTION BASICALY WRITES ALL BYTES TO THE SERIAL PORT WE HAVE PREVIOUSLY DEFINED
 Public Function PLC_Write(ByVal XmtBuf As Object) As Boolean
 Try
 PLC.Write(XmtBuf, 0, XmtBuf.Length)
 Catch
 Debug.Print("COULDNT SEND DATA CHECK PORT")
 End Try

 End Function

 '--- SIMPLE BUTTON ON OUR FORM TO EXIT THE PROGRAM
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 End
 End Sub
End Class

For email coming in and out, I use MS outlook, which makes interfacing with VB very easy.  But if you have configured the outlook client not using exchange, you know that you must specify the time in minutes it will poll to check for email.  Lets say you want to force it to check for new-email at your will.  Well this is how its done, but for this to work you must have the outlook client open.

If you havent please jump this article which shows how to setup your references and other goodies prior to this.

Software:Controlling Insteon devices using an email account

Back here so soon, great!

What are are doing is calling the Microsoft core command bar of the application itself and ‘press’ the button we want to execute, in this case

Were creating instances of the Controls, Tools – > Send/Receive and the account we want to poll. And I don’t have to wait for the application to hit its internal timer.
Sure you can let the timer run but in my case I have my MX records pointing home and host my own pop3 server, so once I get email I notify my server program (In another article soon) to force a scan of my email and act accordingly.  This makes the response to my emails lighting fast.!

So here’s the code,

Function ForceEmailcheck() as boolean

        '------------ Set up the Variables / Objects
        Dim oCtl As Microsoft.Office.Core.CommandBarControl
        Dim oPop As Microsoft.Office.Core.CommandBarPopup
        Dim oCB As Microsoft.Office.Core.CommandBar

        'Use the Send/Receive on All Accounts action in the Tools
        'menu to send the items from the Outbox, and receive new items for my specific account
        oCB = objOutlook.ActiveExplorer.CommandBars("Menu Bar")
        oPop = oCB.Controls("Tools")
        oPop = oPop.Controls("Send/Receive")
        oCtl = oPop.Controls.Item(6)   '----- Please see below why this is a #6 (*)
        oCtl.Execute()  

        '------ return something but not needed to work
        ForceEmailCheck = True
    End Function

* Since your this calls the name of the account itself for example (1.mail.xxxxxx.com) you will need to use that name for this to work, so I ended up using the item # and its easier.
The way to find this out is after you have set up your outlook, copy the above code in your VB and

set a break point at "oPop = oPop.Controls("Send/Receive")"

Then from your ‘Immediate window’ in VB do a query of the item of that control to see where your ‘send/receive’ for your specific account is, (Most likely #6 also)

?oPop.Controls.Item(1),
?oPop.Controls.Item(2)
?oPop.Controls.Item(3)
?oPop.Controls.Item(4)... etc...

Until you find the item you wish to ‘press’ and then insert the # above.    That is how I found the item I was looking for was #6.

And your Set!!

Luis,

As previously mentioned my main program depends 100% off a SQL database, below is a dump of my “Configuration” database, that holds all the system settings.
Many are loaded into memory the first time, or when I run PollDevices query this way the information is updated when needed.  I know its a lot of information but maybe a developer can use these fields as ideas for their program.

Below are my two main functions I’ve created call (get a value or update a value).

Grabbing a value from the “Config” Database

For example this function will return the value of a specific query for example

lg_get_config("wake_up_time")

 Public Function Lg_Get_config(ByVal field As String) As String

       '------ SETUP CONNECTION TO DATABASE (CONNECTION STRING MAY VARY AMONG SYSTEM OR WHERE you have DB)
        Dim sqlConnection35 As New System.Data.SqlClient.SqlConnection(My.Settings.InsteonConnectionString)
        Dim cmd35 As New System.Data.SqlClient.SqlCommand

        '------ SETUP READER TO GRAB THE NECESSARY DATA
        Dim Reader As SqlClient.SqlDataReader
        cmd35.CommandText = "SELECT * FROM Config where config= '" + field.ToLower.Trim + "'"
        cmd35.Connection = sqlConnection35
        sqlConnection35.Open()

'------ OPEN CONNECTION AND CHECK TO MAKE SURE
        Do While sqlConnection35.State <> ConnectionState.Open
        Loop

        Reader = cmd35.ExecuteReader()

        ' --------- check for data, if not return 'FALSE' AND leave function
        If Reader.HasRows = False Then
            Lg_Get_config = False
            Exit Function
        End If
        Reader.Read()

'---------- return the value and close all connections and exit.
        Lg_Get_config = Reader.Item("value")
        Reader.Close()
        sqlConnection35.Close()

    End Function

Setting a value in the “Config” Database

The next example updates a field, and is very similar just that it uses the SQL update command

For example lets say I want to update the “wake_up_time” to something else

lg_set_config("wake_up_time","9:00:00 AM")

    Public Function Lg_Set_config(ByVal field As String, ByVal value As String) As Boolean

        '------------- SETUP CONNECTION
        Dim sqlConnection4 As New System.Data.SqlClient.SqlConnection(My.Settings.InsteonConnectionString)
        Dim cmd4 As New System.Data.SqlClient.SqlCommand
        cmd4.CommandType = System.Data.CommandType.Text
        cmd4.Connection = sqlConnection4

        '------ The Update Command to modify the field
        cmd4.CommandText = "UPDATE Config SET Value= '" + value + "' WHERE config='" + field.Trim.ToLower + "'"
        sqlConnection4.Open()

        '--------- Since we are not getting anything in return this is a NonQuery Executre
        cmd4.ExecuteNonQuery()
        Lg_Set_config = True
        sqlConnection4.Close()
        Update_TimeStamp()  ' - I update the TimeStamp Value so anytime its queried they know is been updated.

    End Function

Data Dictionary The “Config” Database

marker – Int field
config – nvarchar(128)
value – nvarchar(255)
description – nvarchar(255)

* marker field is my primary key, this is also set to “Identity Specification” which means it will autopopulate with a incremental value, so no record is the same, example (1,2,3,4,5,6 etc)

Below is a dump of all my fields and a quick explanation of what they represent.  Descriptions starting with RST are the ones that are updated by the system automatically. For example if I turn on the outside lights, I update the field at that moment to say it has been turned on.

outdoor_turn_off_time 10:32 PM When will all outdoor lights will turn off

outdoor_turnedon Y RST, If outdoor lights are on?
extractor_girls N RST, If the extractor is on or off
extractor_girls_time 10 In Minutes, Timeout for the girls extractor
timer_randomlights N If the random lights are on
random_lights_min 10 Random lights timer in minutes
time_after_sunset_to_turn_on 12 Time in minutes after sunset the lights outside will turn on
temperature 75% RST, Current temperature
temperature_last_read 6:40:29 AM RST, When was the temperature last read
temperature_text Mostly Cloudy RST, Text from NOAA.GOV
temperature_image http://rssweather.cachefly.net/images/weather-symbols/mcloudyn.png RST, Local image
SunRise 6:59:52 AM RST, SunRise in time
SunSet 7:56:07 PM RST, SunSet in Time
Outdoor_turn_on_time 8:08:07 PM RST from program, Outdoor turn on time
fan_off_low 15 Turn off Fan Threshold
fan_on_high 88 Turn on fan Threshold
voicemails N RST,If Voicemails are present?
master_closet_timer 3 Master Closet Timer in Minutes
master_closet N RST,Master Closet is on?
alarm_clock_status ON Mine, Turn on Alarm clock, M-F
poll_devices_interval 525 Minutes to poll each device
poll_devices_next_poll 8/23/2008 15:28 RST, Next time to poll
master_closet_turn_off_time 8/22/2008 22:39 RST, Master Closet
extractor_girls_turn_off_time 8/22/2008 21:46 RST,Girls Turn off Extractor time
Entrance_turnedon N RST, Is entrance on?
entrace_turn_on_time 8:01:07 PM RST, What time to turn entrance on
time_after_sunset_entrance_turn_on 5 Time to turn on Entrace after SunSet in Minutes
house_state NIGHT House State (E,O,I)
wake_up_time 6:15:00 AM Master Wake up time, M-F only
time_after_sunrise_to_turn_off 10 Time after SunRise to turn off Nook (Sat and sun Only)
incomming_call N CallerID Found? – No Longer Used
incomming_stamp 8/22/2008 17:29 RST, TimeStamp to clear call (No longer used)
incomming_name Luis Garcia RST, Caller ID
incomming_image luis.png RST, Imaged pulled from Contacts DB
incomming_date 8/22/2008 17:29 RST, Incomming Time
incomming_number xxxxxxxxxx RST, Incomming Number
entrance_turn_off_pre -5 Time in minutes before turn off time to turn off the entrance only
entrance_turn_off_pre_time 10:27:00 PM From program result of entracne_Trun_off_pre
motion_hallway N Motion is detected in hallway
extractor_master N If the extractor is on or off
extractor_master_time 10 Timeout for Extrator Master
extractor_master_turn_off_time 8/23/2008 6:18 RST,Master Turn off Extractor time
sensor_hallway N IF Hallway Sensor is on
sensor_hallway_time 6 Timeout Hallway
sensor_hallway_turn_off_time 8/23/2008 6:14 Hallway Timeout
sensor_hallway_bypass N Set to N if normal and Y to ignoreTimer
sensor_entrance_last_seen 8/23/2008 2:48 RST, Last time movement was detected
sensor_entrance_rescan_timeout 3 Minutes before the entrance sends out another signal
sensor_entrance_bypass Y If sensor entrance is bypassed (Y)=dont check (N)=yes check
sensor_master_closet_bypass N If sensor master is bypassed (Y)=dont check (N)=yes check
sensor_hallway_last_seen 8/23/2008 6:08 RST, Last time movement was detected
sensor_master_bathroom_last_seen 8/23/2008 6:09 RST,Last time movement was detected in master batrhoom
sensor_den_last_seen 8/22/2008 23:05 RST,Last time movement was detected in DEN
sensor_garage_last_seen 8/22/2008 20:59 RST,Last time movement was detected in Garage
sensor_hallway_start_time 6:00:00 PM Time that the Sensor will kick in. Usually set 3pm since its day time it wont turn on
sensor_garage_door_state CLOSED Garage door if open
temperature_last_read_wdw 6:40:29 AM Last time temperature was read for WDW
sensor_outside_bathroom_last_seen 8/23/2008 0:25 RST,Last time movement was detected in master batrhoom
sensor_outside_bathroom_timeout 25 Outside bathroom timeout
sensor_outsidebathroom_enabled Y RST, Enabled or not?
music_playing_status N RST, Is Radio Music Playing
sensor_garage_door_state_last 8/22/2008 20:58 RST, Last time Garage was open or closed
sensor_garage_door_timer 6/23/2008 20:48 RST, Time is has been opened
decorations_status OFF Status of all decorations
sensor_den_timer 8/22/2008 23:10 RST, Time the Den will turn off it no movement
sensor_den_timer_timeout 5 Minutes, Den will turn off after no activity
sensor_master_closet_last_seen 8/22/2008 22:36 RST, MasterCloset Last Seen
decorations_on 7:58:07 PM Time Decorations turn on
decorations_off 10:45:00 PM Time Decorations turn off
decorations_after_sunset_on 2 Decorations turn on after sunset
speakers_status OFF RST, if speakers are on
coffee_machine_status TRUE CoffeeMachine timer if on or OFF
coffee_machine_timer 6:20:00 AM CoffeeMachine OnTime
sensor_laundry_last_seen 8/22/2008 21:30 RSt, LAST seen activity in Laundry
sensor_laundry_timeout 3 Minutes before laundry turns off
sensor_laundry_timer 8/22/2008 21:33 RST, When will it turn off
kelly_alarm_on 6:15:00 AM Kelly On_Time
kelly_alarm_status ON IF Kellys alarm is on or off
barbie_alarm_on 7:01:00 AM Barbie OnTime
barbie_alarm_status ON Barbie on-time
back_house_lights_on 9:00:00 PM When will the backlights turn on
back_house_lights_off 9:30:00 PM When will the backlights turn off
guilda_alarm_on 6:15:00 AM Guildas Light will turn on
guilda_alarm_status ON Guildas Alarm status
kelly_alarm_song S:\Mp3\Hanna Montana6 – I Got Nerve.mp3 Kelly AlarmSong
barbie_alarm_song S:\Mp3\Abba\(1994) Thank You For The Music\Disc 1\21 – Abba – My Love, My Life.mp3 Kelly AlarmSong
kelly_artist_songs1 hanna mon Kelly selected artist for Alarm
kelly_artist_songs2 vanessa Kelly selected artist for Alarm
kelly_artist_songs3 ashley tins Kelly selected artist for Alarm
barbie_artist_songs1 cascada Barbie Selected artist for Alarm
barbie_artist_songs2 Abba Barbie Selected artist for Alarm
barbie_artist_songs3 Rick Springfield Barbie Selected artist for Alarm
kelly_alarm_song_title Hanna Montana – I Got Nerve Last song Played
barbie_alarm_song_title ABBA – My Love, My Life Last song Played

Here are my screens so far.  As you can see there is now text that is dynamically populated.
I picked a relative small window, in this case 574.1 x 430.05 and work everthing in that, cleaner and simple.

The Jukebox function basically tells my server to open a HTML page and play a radio URL.
you can find that article here Software:Play WAV,MP3 and Playlists, from your program.

Master Bedroom Screen, I’ve added little dots next to the devices to see if there on or off.
I show how I did this in the next article.

Here I’ve also populated the bottom of the Den,Hallway with the motion sensor data, this way
you can see when there was last activity, also the bulbs show the light status.

Yep, the notification screen, its the only way to unglue them from their PC’s
I wonder where they got it from.  That is done

The Special Features menu.  Also populate the information for the Garage Motion sensors and last time it was opened.

I’ve moved that page to the Main Page since I update it frequently.

That page has been moved here

Hi, in a previous article I had shown how to monitor & capture data on a specific port using VB. Mainly to allow my server send out notification to the clients, like a Caller ID Alert. That article can be found here

How to monitor and capture data in a specific port in VB / 2005

Below I’ll show the code I use on the server side to actually open and send the information to the clients.

Like mentioned above I will use the example of a caller Id alert , so the program will open a port 81 and send the text ‘callerid’ to the clients (In this case 192.168.0.106). You can use PC names if you have a home router like D-link etc.

Since I have a couple of clients I use VB ‘commandline’ feature to retrieve the IP, port and message that I am going to send.  My utility is called ‘BumpClients’.  For the example lets say this how its called

“Bumpclients.exe 192.168.0.106 callerid 81”

—————— Setting up the imports, make sure you include System.Net and System.net.Sockes, the others may not be needed

Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Imports System.Xml.XPath
Imports System.IO
Imports System.Net
Imports System.Net.Sockets
Imports System.Data
Imports System
Imports System.Drawing
Imports System.Windows.Forms

Public Class Form1

'------------------------------ Create the instance to of the TCP Client (Its the same as receiving)
    Public WithEvents OpenPort As TcpClient  

'------ I use the Form_load event to quickly send the message and exit the program, no user interaction is needed, we grab all paramters from the command line when called.
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Minimized '- Go hidden
        Me.Hide() '- Go hidden

'------ Next using the Split command I grab the three parameters by looking for the space( This will give me the IP,the command,and port the program will use!)
'------ Data(0)=IP, Data(1)=command, Data(2)=port.

        Dim IP As String
        Dim datA_out
        Dim port As Integer

        data_out = Split(Command$(), " ")
        IP = data_out(0)
        port = data_out(2)

'------ Just a quick check to make I can ping the IP, if not just exit and dont even bother.
        If My.Computer.Network.Ping(IP) = False Then End

'---- The actualy opening of the port un a 'try' statement if it fails exit also
        Try
            OpenPort = New TcpClient(IP, port)
        Catch
            End
        End Try

'------ If all is good then go ahead and convert our text to bytes and send it out using the stream method!
       Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes(Trim(data_out(1)))

        Dim stream As NetworkStream = OpenPort.GetStream()
        stream.Write(data, 0, data.Length)

'------ Close and exit!- That's it!
        stream.Close()
        OpenPort.Close()
        End
    End Sub
End Class

A important note, remember that on your client you need to open the port you use in the firewall or it will never see anything, but you dont need to open it on the server since it will be sending.  To test this you will need the two actual computers sine you cant monitor and send data thru the same port.

In my application I actually run a external program using the system.diagnostics,process.start command, to the IP of my PC’s this way, it will run each script and not wait.And each of time will exit accordingly.

data_out=”callerid”
port=81

System.Diagnostics.Process.Start(“C:\vb\Insteon_BumpClients\BumpClients\BumpClients\bin\Release\BumpClients.exe”, ” 192.168.0.102 ” + data_out + ” ” + port) ‘ Laptop
System.Diagnostics.Process.Start(“C:\vb\Insteon_BumpClients\BumpClients\BumpClients\bin\Release\BumpClients.exe”, ” 192.168.0.120 ” + data_out + ” ” + port) ‘
System.Diagnostics.Process.Start(“C:\vb\Insteon_BumpClients\BumpClients\BumpClients\bin\Release\BumpClients.exe”, ” 192.168.0.104 ” + data_out + ” ” + port) ‘

Enjoy!