| | |
VB.Net Networking Heartbeat
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 1
Reputation:
Solved Threads: 0
i need help on programming networking..
i'm creating a winservice called HeartBeat. this service is to check if the gateway(list of gateway) is alive and able to do certain process( other application) and if it's down after certain tries, it will notified related person(email/sms/voicemail).
We a doing terminal application for WAN. My supervisor told that last time he got issue as the terminal process fail. The gateway is alive but the process still fail. And later he found out that the response came from proxy, not the actual gateway behind it(gateway is down).
My supervisor told me that to write "+++" to the port of the gateway(ipaddress). He said this will not write to the port physicall but send bytes to that port.
the theory is like this..
tcpclient.Connect(ip,port)
ns as networkstream = tcpclient.getstream()
if(ns.canwrite)
I found out that networkstream only send the data to buffer and return after it finishes writing to buffer.It will not wait for the buffer finish sending to destination.
my issue is
- networkstream does not return anything. then how do i know if the data is successfully sent to the gateway
- networkstream.canwrite is not actually writing to the port also.
it only check if it can write to the stream
my view is, i can achieve this if the gateway writes back to me..
below is my basic code for this app.
i'm creating a winservice called HeartBeat. this service is to check if the gateway(list of gateway) is alive and able to do certain process( other application) and if it's down after certain tries, it will notified related person(email/sms/voicemail).
We a doing terminal application for WAN. My supervisor told that last time he got issue as the terminal process fail. The gateway is alive but the process still fail. And later he found out that the response came from proxy, not the actual gateway behind it(gateway is down).
My supervisor told me that to write "+++" to the port of the gateway(ipaddress). He said this will not write to the port physicall but send bytes to that port.
the theory is like this..
tcpclient.Connect(ip,port)
ns as networkstream = tcpclient.getstream()
if(ns.canwrite)
ibyte = ns.write("+++")end if
if(ibyte>0) then//assume reaconnectionend if
I found out that networkstream only send the data to buffer and return after it finishes writing to buffer.It will not wait for the buffer finish sending to destination.
my issue is
- networkstream does not return anything. then how do i know if the data is successfully sent to the gateway
- networkstream.canwrite is not actually writing to the port also.
it only check if it can write to the stream
my view is, i can achieve this if the gateway writes back to me..
below is my basic code for this app.
VB.NET Syntax (Toggle Plain Text)
Public Sub StartBeat(ByVal pstIpAddress As String, ByVal pstPortNo As String, ByVal pstMaxTries As Integer) Dim tcpClient As New System.Net.Sockets.TcpClient() Dim Bytes2Write As [Byte]() = Encoding.ASCII.GetBytes("+++") If (pstMaxTries = 0) Then pstMaxTries = 1 End If Dim tries As Integer = 0 For tries = 0 To pstMaxTries Try tcpClient.Connect(pstIpAddress, pstPortNo) Dim nstream As NetworkStream = tcpClient.GetStream() fstErrmsg = Write2Port(nstream, Bytes2Write, tcpClient) If (String.IsNullOrEmpty(fstErrmsg)) Then Exit For End If nstream.Close() Catch ex As Exception fstErrmsg = ex.Message End Try If (tries = pstMaxTries) Then 'sendemail End If Next If (tcpClient.Connected = True) Then tcpClient.Close() End If End Sub Private Function Write2Port(ByVal ns As NetworkStream, ByVal lBbyte As Byte(), ByVal tcpClient As TcpClient) Dim lstErrmsg As String = String.Empty Try If (ns.CanWrite) Then ns.Write(lBbyte, 0, lBbyte.Length) 'Dim ReceiveByte As Byte = tcpClient.ReceiveBufferSize Else lstErrmsg = "Error: Cannot write data to stream" End If Catch ex As Exception lstErrmsg = ex.Message End Try Return lstErrmsg End Function
![]() |
Similar Threads
- Need Freelance ASP.NET, MS SQL, C#, VB.NET Developer (Web Development Job Offers)
- Senior .Net Developer - E-Commerce (not a recruitment agency role) (Web Development Job Offers)
- Looking for Senior .NET Architect (Software Development Job Offers)
- ConnectMemories.net - A Social Networking Site (Website Reviews)
- Network Problems (Windows NT / 2000 / XP)
- ProgrammersTalk.net Recruiting Forum Posters (Internet Marketing Job Offers)
- Sharing files ..... (Windows NT / 2000 / XP)
- Linksys BEFSX41 vpn question (Networking Hardware Configuration)
- Very Slow Boot When Networking (Windows tips 'n' tweaks)
- WinNT Networking Tips (Networking Hardware Configuration)
Other Threads in the VB.NET Forum
- Previous Thread: Store data in variables
- Next Thread: How to stop data grid view from adding new row until two fields are populated?
Views: 613 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for networking, port, socket, tcp, vb.net
2.0 access administration agp api application array asp.net basic beginner bing browsing bugs business c# chat client convert cuesent database datagridview deploy development ethernet events excel expose facebook facelift firewall forwarding function google government hash homework hp ibdg images infrastructure internet ip java jobs listener mailserver map marketing media messenger mobile mozilla ms myspace networking news objects open picturebox plugin politics port printer printing programming project proxy python recv router routers ruby security serial server settings soap social socialnetwork socket sockets software sql sqldatbase sqlserver2005 storage tcp technology textbox twitter vb vb.net visual visualbasic visualbasic.net visualstudio warning web wifi wireless






