Thank you for your answer! I did this and tried to see if the windows service is listening:
Code:
Imports System.Net.sockets
Public Class Calculate
Private listener As Net.Sockets.TcpListener
Const PORT_NUM As Integer = 1039
Dim EndPoint As Net.IPEndPoint
Protected Overrides Sub OnStart(ByVal args() As String)
'ip : 10.80.109.132 gives:'
Dim iip As Long = 16777343
'ip localhost : 127.0.0.1'
EndPoint = New Net.IPEndPoint(iip, 1039)
listener.Server.Bind(EndPoint)
listener.Start()
Dim data As String
Dim bytes(1024) As Byte
While True
Dim client As TcpClient = listener.AcceptTcpClient()
data = Nothing
Dim Stream As NetworkStream = client.GetStream()
Dim i As Int32
i = stream.Read(bytes, 0, bytes.Length
While (i <> 0)
data = System.Text.Encoding.ASCII.GetString(bytes, 0, i)
Dim nb1, nb2, nb3 As Double
Dim table As Array = data.Split("/")
nb1 = Double.Parse(table.GetValue(0))
nb2 = Double.Parse(table.GetValue(1))
nb3 = nb1 + nb2
Dim fin As String = nb3.ToString
Dim Content() As Byte = System.Text.Encoding.ASCII.GetBytes(fin.ToCharArray())
Stream.Write(Content, 0, Content.Length)
i = Stream.Read(bytes, 0, bytes.Length)
End While
client.Close()
End While
End Sub
Protected Overrides Sub OnStop()
listener.Stop()
End Sub
End Class
Bookmarks