Monitoring PING and responding

I wish to monitor either the pings or the fingers that the computer recieves, and, in response to a certain number, perform an action such as run a batch program. I am unsure as to which programming area to post this question under, so suggestions are welcome. Thank you...
dog78Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mcriderCommented:
Systems respond to ping using ICMP packets.  This is performed at the OS level and there is no way to count the number of pings that are received in VB.

Finger, on the other hand (no pun indended) operates on TCP port 79.  You could write an application that listens on port 79 and return the finger information, and keep track of the number of requests in your application.

Hope this helps...


cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dog78Author Commented:
Do you know of any documentation regarding this task in VB? Also, I wish to have an event occur resulting from the reception of a finger.
0
mcriderCommented:
This quote is from the "Internet Protocols Handbook" by Dave Roberts, $35.99, Coriolis Group Books:

"The finger protocol is extremely simple. The finger client first makes contact with the finger server at the well-known port number. The client sends the server a query consisting of a single line of ASCII text followed by a CRLF end-of-line sequence.  The server returns one or more lines of text to the client and then closes the connection. After receiving the reply lines, the client closes the connection and the session is finished."

So for example the client sends:

    "mcrider" + VbCrLf

the server can respond:

    "Login: mcrider    Name: mike" + vbCrLf
    "Directory: /home/mcrider" + VbCrLf
    "No other information available" + VbCrLf


You can use the winsock control to perform the finger server function.  If you need an example of using the winsock control I have a very small chat server that can help you.


Cheers!
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

dog78Author Commented:
Well, lemmi just tell you what I'm trying to do and perhaps you know of a relatively simple way, even if it does not involve Finger or Ping.

I have one computer with constant internet access (via network) and I wish to have this computer perform routine tasks (via BAT file) at my request. I considered a scheduler, but my schedules dont follow any rules, so I'd have to be constantly re-scheduling. Therefore, I need a way of "signalling" this computer to execute the BAT file. I wish this to be a non-interfering transparent process, ie. I want the computer to be usable even when the processes are running.
0
mcriderCommented:
Here is a quick and dirty "restricted" Telnet server you can run in VB.  While the program is running, you can telnet into the system, login and do commands.

Just start a new project and add a winsock control to form1.  Set the Winsock1 INDEX PROPERTY to 0 and then paste the following code into the Declaration Section of Form1.

In the Winsock1_DataArrival event, there is a section where you can handle your own commands... Just put the command you want to handle as a case statement and then do whatever you want the command to do... shell a dos command, write information back to the client, it's pretty much up to you. Right now, the only commands handled are "QUIT" and "EXIT".

Don't forget to set the USERNAME and PASSWORD constants to whatever you want...



Cheers!


THE CODE:


Const USERNAME = "mcrider"
Const PASSWORD = "helloworld"
Private Sub Form_Load()
    Winsock1(0).LocalPort = 23
    Winsock1(0).Listen
End Sub
Private Sub Winsock1_Close(Index As Integer)
    Winsock1(Index).Close
    DoEvents
    Unload Winsock1(Index)
End Sub
Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal requestID As Long)
    Dim iVal As Integer
    iVal = Winsock1.Count
    Load Winsock1(iVal)
    With Winsock1(iVal)
        .Tag = "0"
        .Accept requestID
        .SendData "Login: "
        DoEvents
    End With
End Sub


Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)
    Dim xCmd As String
    Dim xBuf As String
    Dim iVal As Long
   
    With Winsock1(Index)
        .GetData xBuf, vbString
        .Tag = .Tag + xBuf
        iVal = InStr(1, .Tag, vbCrLf)
        If Not iVal = 0 Then
            xBuf = Left$(.Tag, iVal - 1)
            Select Case Left$(xBuf, 1)
                Case "0"
                    If UCase$(Mid$(xBuf, 2)) = UCase$(USERNAME) Then
                        .Tag = "1"
                        .SendData "Password: "
                    Else
                        .Tag = "0"
                        .SendData "Login: "
                    End If
                Case "1"
                    If UCase$(Mid$(xBuf, 2)) = UCase$(PASSWORD) Then
                        .Tag = "2"
                        .SendData "Welcome " + USERNAME + vbCrLf + "COMMAND> "
                    Else
                        .Tag = "0"
                        .SendData "Login: "
                    End If
                Case "2"
                    xCmd = Mid$(xBuf, 2)
                    .Tag = "2" + Mid$(.Tag, iVal + 2)
                    '========================================================
                    'PUT CODE FOR YOUR VALID COMMANDS HERE AS CASE STATEMENTS
                    '========================================================
                    Select Case Trim$(UCase$(xCmd))
                        Case "QUIT", "EXIT"
                            .SendData "Good-bye!" + vbCrLf + vbCrLf
                            DoEvents
                            Winsock1_Close .Index
                            Exit Sub
                        Case Else
                            .SendData "Invalid Command: [" + xCmd + "]"
                    End Select
                    '========================================================
                    'END OF VALID COMMANDS
                    '========================================================
                    .SendData vbCrLf + "COMMAND> "
                Case Else
                    .Tag = "0"
                    .SendData "Login: "
            End Select
        End If
    End With
    DoEvents
End Sub
0
dog78Author Commented:
Thank you, this should serve well for my purposes.
0
mcriderCommented:
Glad I could help!

Cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.