Fetstil Fetstil Kursiv Understrykning linje färgläggning tabellverk Punktlista Nummerlista Vänster Centrerat högerställt Utfyllt Länk Bild htmlmode
  • Forum & Blog
    • Forum - översikt
      • .Net
        • asp.net generellt
        • c#
        • vb.net
        • f#
        • silverlight
        • microsoft surface
        • visual studio .net
      • databaser
        • sql-server
        • databaser
        • access
        • mysql
      • mjukvara klient
        • datorer och komponenter
        • nätverk, lan/wan
        • operativsystem
        • programvaror
        • säkerhet, inställningar
        • windows server
        • allmänt
        • crystal reports
        • exchange/outlook
        • microsoft office
      • mjukvara server
        • active directory
        • biztalk
        • exchange
        • linux
        • sharepoint
        • webbservers
        • sql server
      • appar (win/mobil)
      • programspråk
        • c++
        • delphi
        • java
        • quick basic
        • visual basic
      • scripting
        • asp 3.0
        • flash actionscript
        • html css
        • javascript
        • php
        • regular expresssion
        • xml
      • spel och grafik
        • DirectX
        • Spel och grafik
      • ledning
        • Arkitektur
        • Systemutveckling
        • krav och test
        • projektledning
        • ledningsfrågor
      • vb-sektioner
        • activeX
        • windows api
        • elektronik
        • internet
        • komponenter
        • nätverk
        • operativsystem
      • övriga forum
        • arbete karriär
        • erbjuda uppdrag och tjänster
        • juridiska frågor
        • köp och sälj
        • matematik och fysik
        • intern information
        • skrivklåda
        • webb-operatörer
    • Posta inlägg i forumet
    • Chatta med andra
  • Konto
    • Medlemssida
    • Byta lösenord
    • Bli bonsumedlem
    • iMail
  • Material
    • Tips & tricks
    • Artiklar
    • Programarkiv
  • JOBB
  • Student
    • Studentlicenser
  • KONTAKT
    • Om pellesoft
    • Grundare
    • Kontakta oss
    • Annonsering
    • Partners
    • Felanmälan
  • Logga in

Hem / Forum översikt / inlägg

Posta nytt inlägg


Behöver hjälp med ett Script (om en DC-hub är online eller inte)

Postades av 2004-09-12 22:13:09 - Johan Svensson, i forum asp.net generellt, Tråden har 8 Kommentarer och lästs av 2860 personer

som rubriken lyder,, jag vill kunna visa på en hemsida om en DC-hub är inline eller inte...

Hemsida och dc-hubben är på olika datorer...

Vi i våran förening har startat en DC-hubb där vi delar med oss av egen-inspelat material
från träffar och evenemang...

och jag vill kunna visa på vår hemsida om hubben är online eller inte..

hur gör man det?

Jag skriver all kod i ASP.NET (VB)

Mvh
Johan.NET


Svara

Sv: Behöver hjälp med ett Script (om en DC-hub är online eller inte)

Postades av 2004-09-13 08:42:33 - Pelle Johansson

Nu är ju jag rudis på vad en dc-hub är men frågan är om det finns någon ipadress på den eller om det går att köra smtp mot den eller liknande? Om det går kan du även från .net utföra detta relativt smärtfritt. Så frågan bollas väl tillbaks till dig och så får du fundera på vad den klarar oavsett om det är en hemsida som snackar med den eller någon annan programvara - eller om den helt enkelt är dum och inte är nåbar?! Så tyvärr kan jag inte ge dig råd och tips för jag saknar den kunskapen.


Svara

Sv: Behöver hjälp med ett Script (om en DC-hub är online eller inte)

Postades av 2004-09-13 09:25:28 - Mikael Johansson

Precis som Pelle är inne på så går DC på IP-nummer. Det lättaste borde vara att via ett script göra en förfrågan mot det IP som servern ligger på. Får man svar bör servern vara online.


Svara

Sv: Behöver hjälp med ett Script (om en DC-hub är online eller inte)

Postades av 2004-09-13 10:31:11 - Pelle Johansson

I så fall kan du skriva något i stil med denna klass för att utföra ping via asp.net

Fann även denna kod du kan titta på som referens: http://www.thecodeproject.com/vb/net/MyLanApp.asp

Imports System.Net.Sockets
Imports System.Net
Imports System
Imports System.Runtime.InteropServices

Namespace ICMP_Packet

    ' Define the structure of an ICMP packet.
    ' This structure contains packet information.
    Structure IcmpPacket

        Dim type_message As Byte                ' type of message
        Dim subCode_type As Byte                ' type of sub-code
        Dim complement_checkSum As UInt16       ' one's complement checksum for the structure
        Dim identifier As UInt16                ' identifier
        Dim sequenceNumber As UInt16            ' sequence number  
        Dim data() As Byte                      ' data


        Public Sub Initialize(ByVal type As Byte, ByVal subCode As Byte, ByVal payload() As Byte)
            Dim index As Integer
            Dim buffer_icmpPacket() As Byte
            Dim cksumBuffer() As UInt16
            Dim icmpHeaderBufferIndex As Int32 = 0
            Me.type_message = type
            Me.subCode_type = subCode
            complement_checkSum = UInt16.Parse("0")
            identifier = UInt16.Parse("45")
            sequenceNumber = UInt16.Parse("0")
            data = payload

            ' Declare a variable to store the total packet size.
            ' Call the Serialize method to count the total number of bytes in the packet.
            buffer_icmpPacket = Serialize()

            ' Resize a UInt16 array to half the size of the packet.
            ReDim cksumBuffer((buffer_icmpPacket.Length() \ 2) - 1)

            ' Initialize the UInt16 array.
            For index = 0 To (cksumBuffer.Length() - 1)
                cksumBuffer(index) = BitConverter.ToUInt16(buffer_icmpPacket, icmpHeaderBufferIndex)
                icmpHeaderBufferIndex += 2
            Next index

            'Call a method that returns a checksum.
            complement_checkSum = MCheckSum.Calculate(cksumBuffer, cksumBuffer.Length())
        End Sub

        Public Function Size() As Integer
            Return (8 + data.Length())
        End Function

        ' The Serialize method converts the packet to a byte array to calculate the total size.
        Public Function Serialize() As Byte()
            Dim b_seq() As Byte = BitConverter.GetBytes(sequenceNumber)
            Dim b_cksum() As Byte = BitConverter.GetBytes(complement_checkSum)
            Dim b_id() As Byte = BitConverter.GetBytes(identifier)
            Dim index As Int32 = 0
            Dim buffer() As Byte
            ReDim buffer(Size() - 1)

            ' Serialize the structure into the array.
            buffer(0) = type_message
            buffer(1) = subCode_type
            index += 2
            Array.Copy(b_cksum, 0, buffer, index, 2)
            index += 2
            Array.Copy(b_id, 0, buffer, index, 2)
            index += 2
            Array.Copy(b_seq, 0, buffer, index, 2)
            index += 2

            ' Copy the data.
            If (data.Length() > 0) Then
                Array.Copy(data, 0, buffer, index, data.Length())
            End If
            Return buffer
        End Function
    End Structure

    ' The CPing class.
    Public Class CPing

        Private Const DEFAULT_TIMEOUT As Integer = 1000
        Private Const SOCKET_ERROR As Integer = -1
        Private Const PING_ERROR As Integer = -1
        Private Const ICMP_ECHO As Integer = 8
        Private Const DATA_SIZE As Integer = 32
        Private Const RECV_SIZE As Integer = 128

        Private _open As Boolean = False
        Private _initialized As Boolean
        Private _recvBuffer() As Byte
        Private _packet As IcmpPacket
        Private _hostName As String
        Private _server As EndPoint
        Private _local As EndPoint
        Private _socket As Socket

        Public Sub New(ByVal hostName As String)
            Me.HostName() = hostName
            ReDim _recvBuffer(RECV_SIZE - 1)
        End Sub

        Public Sub New()
            ' Set the default host name to the local host.
            Me.HostName() = Dns.GetHostName()
            ReDim _recvBuffer(RECV_SIZE - 1)
        End Sub

        Private Overloads Sub finalize()
            ' Ensure that you close the socket.
            Me.Close()
            Erase _recvBuffer
        End Sub

        ' Get and set the current host name.
        Public Property HostName() As String
            Get
                Return _hostName
            End Get
            Set(ByVal Value As String)
                _hostName = Value
                ' If the CPing object is already open, close it and then reopen it by using a new host name.
                If (_open) Then
                    Me.Close()
                    Me.Open()
                End If
            End Set
        End Property

        ' Get the state (open or closed).
        Public ReadOnly Property IsOpen() As Boolean
            Get
                Return _open
            End Get
        End Property

        ' Create a socket to host remote end points and local end points.
        Public Function Open() As Boolean
            Dim payload() As Byte

            If (Not _open) Then
                Try
                    ' Initialize the packet.
                    ReDim payload(DATA_SIZE)
                    _packet.Initialize(ICMP_ECHO, 0, payload)

                    ' Initialize an ICMP socket.
                    _socket = New Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp)

                    ' Set the server end point.
                    If _hostName.ToLower.IndexOfAny("abcdefghijklmnopqrstuvwxyz-") >= 0 Then
                        _server = New IPEndPoint(Dns.GetHostByName(_hostName).AddressList(0), 0)
                    Else
                        _server = New IPEndPoint(IPAddress.Parse(_hostName), 0)
                    End If

                    ' Set the receiving end point as your client computer.
                    _local = New IPEndPoint(Dns.GetHostByName(Dns.GetHostName()).AddressList(0), 0)
                    _open = True
                Catch
                    Return False
                End Try
            End If
            Return True
        End Function

        ' Destroy the socket and end points (if necessary).
        Public Function Close() As Boolean
            If (_open) Then
                _socket.Close()
                _socket = Nothing
                _server = Nothing
                _local = Nothing
                _open = False
            End If
            Return True
        End Function

        ' Perform a PING operation.
        Public Overloads Function Ping() As Integer
            Return Ping(DEFAULT_TIMEOUT)
        End Function

        ' The Ping method performs a PING operation.
        Public Overloads Function Ping(ByVal timeOutMilliSeconds As Integer) As Integer

            ' Initialize the time-out value.
            Dim timeOut As Integer = timeOutMilliSeconds + Environment.TickCount()

            ' Send the packet.
            Try
                If (SOCKET_ERROR = _socket.SendTo(_packet.Serialize(), _packet.Size(), 0, _server)) Then
                    Return PING_ERROR
                End If
            Catch
                Return PING_ERROR
            End Try

            ' Use the following loop to check the response time until you receive a time-out.
            Do
                ' Poll the read buffer every millisecond.
                ' If data exists, read the data and return the round-trip time.
                If (_socket.Poll(1000, SelectMode.SelectRead)) Then
                    _socket.ReceiveFrom(_recvBuffer, RECV_SIZE, 0, _local)
                    Return (timeOutMilliSeconds - (timeOut - Environment.TickCount()))
                ElseIf (Environment.TickCount() >= timeOut) Then
                    Return PING_ERROR
                End If
            Loop While (True)
        End Function
    End Class

    ' The MCheckSum module contains the static Calculate method.
    Module MCheckSum
        <StructLayout(LayoutKind.Explicit)> _
                   Structure UNION_INT16
            <FieldOffset(0)> Dim lsb As Byte      ' Least significant byte
            <FieldOffset(1)> Dim msb As Byte      ' Most significant byte
            <FieldOffset(0)> Dim w16 As Short
        End Structure

        <StructLayout(LayoutKind.Explicit)> _
        Structure UNION_INT32
            <FieldOffset(0)> Dim lsw As UNION_INT16     ' Most significant word
            <FieldOffset(2)> Dim msw As UNION_INT16     ' Least significant word
            <FieldOffset(0)> Dim w32 As Integer
        End Structure

        ' The Calculate method calculates the checksum value.
        Public Function Calculate(ByRef buffer() As UInt16, ByVal size As Int32) As UInt16
            Dim counter As Int32 = 0
            Dim cksum32 As UNION_INT32
            Do While (size > 0)
                cksum32.w32 += Convert.ToInt32(buffer(counter))
                counter += 1
                size -= 1
            Loop

            cksum32.w32 = cksum32.msw.w16 + cksum32.lsw.w16 + cksum32.msw.w16
            Return Convert.ToUInt16(cksum32.lsw.w16 Xor &HFFFF)
        End Function
    End Module
End Namespace


Svara

Sv: Behöver hjälp med ett Script (om en DC-hub är online eller inte)

Postades av 2004-09-14 11:14:02 - Johan Svensson

Tack för svaren...!

Nu kommer nästa fråga... =)

Den kan vara så att datorn är igång, men inte själva programmet DC (Direct Connect)

Och jag vet att programmet lyssnar på port: 411

Så kan man pinga och se om denna port svarar ?

Mvh
Johan.NET


Svara

Sv: Behöver hjälp med ett Script (om en DC-hub är online eller inte)

Postades av 2004-09-14 11:19:47 - Mikael Åhlén

Jag vet inte vilken kod du har kollat på men exemplet ovan så ser det ut så här

checkServer("farscape.myftp.org", 821)



821 är porten (om jag inte är helt ute och cyklar).


Svara

Sv: Behöver hjälp med ett Script (om en DC-hub är online eller inte)

Postades av 2004-09-14 14:07:26 - Johan Svensson

Oj, det missade jag.... Tack!

Mvh
Johan.NET


Svara

Sv: Behöver hjälp med ett Script (om en DC-hub är online eller inte)

Postades av 2004-09-15 17:02:35 - Mikael Åhlén

Jag som är ute efter samma sak som dig, hur går det?


Svara

Sv: Behöver hjälp med ett Script (om en DC-hub är online eller inte)

Postades av 2004-09-15 17:21:10 - Johan Bovin

Jag har inte kollat eller läst så noga men ni kanske kan tittar på hur detta är uppbyggt för att få idéer till hur man kan göra:
http://dc-sharp.sourceforge.net/


Svara

Nyligen

  • 09:09 Vill du köpa medicinska tester?
  • 12:47 Vem beviljar assistansen – kommune
  • 14:17 Någon med erfarenhet av hemstädnin
  • 14:14 Bör man använda sig av en båtförme
  • 14:12 Finns det någon intressant hundblo
  • 14:25 Tips på verktyg för att skapa QR-k
  • 14:23 Tips på verktyg för att skapa QR-k
  • 20:52 Fungerer innskuddsbonuser egentlig

Sidor

  • Hem
  • Bli bonusmedlem
  • Läs artiklar
  • Chatta med andra
  • Sök och erbjud jobb
  • Kontakta oss
  • Studentlicenser
  • Skriv en artikel

Statistik

Antal besökare:
Antal medlemmar:
Antal inlägg:
Online:
På chatten:
4 569 604
27 953
271 705
6 633
0

Kontakta oss

Frågor runt konsultation, rådgivning, uppdrag, rekrytering, annonsering och övriga ärenden. Ring: 0730-88 22 24 | pelle@pellesoft.se

© 1986-2013 PelleSoft AB. Last Build 4.1.7169.18070 (2019-08-18 10:02:21) 4.0.30319.42000
  • Om
  • Kontakta
  • Regler
  • Cookies