Announcement

Collapse
No announcement yet.

sending data on tcp

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    sending data on tcp

    Hi everyone!
    I am trying to send some data to an other computer on lan using homeseer scripts. I am trying to run the following simple script but it is not getting executed.
    Imports System.Net
    Imports System.Net.Sockets

    Public Sub Main(ByVal sender As Object)

    Dim tcpClient As New System.Net.Sockets.TcpClient()
    tcpClient.Connect("127.0.0.1", 8000)
    Dim networkStream As NetworkStream = tcpClient.GetStream()

    If networkStream.CanWrite And networkStream.CanRead Then
    Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("testing")
    networkStream.Write(sendBytes, 0, sendBytes.Length)
    Else
    If Not networkStream.CanWrite Then
    tcpClient.Close()
    End If
    End If

    End Sub

    The error messages on log are as follows

    6/13/2007 11:56:39 AM - Error - Script compile error: Name 'Encoding' is not declared.on line 24

    6/13/2007 11:56:39 AM - SCR - Option Strict OffImports System.NetImports System.Net.Socketsimports Schedulerimports SystemPublic Module scriptcode2#Region "Automatically generated code, do not modify"'Automatically generated code, do not modify'Event Sources Begin <system.contextstaticatt>

    Pl. help me out. I am also unable to find ipmanager plugin in the updater.</system.contextstaticatt>

    #2
    It should be possible to do this via scripting. Another option is with mcsXap plugin http://board.homeseer.com/showthread.php?t=119121 that contains a scripting method for TCP communication. It will make a connection, send the data and close the connection.

    &hs.Plugin("mcsXap").SendTCP(sIP , iPort , sData )

    Comment


      #3
      At the end of this thread is the working code I wrote in VB.Net, for this.

      I suspect you need an:

      Imports System.Text

      Comment

      Working...
      X