Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - chat no-ip
Forum - C# / VB.NET - chat no-ip

Avatar
puzz1998 (Normal User)
Newbie


Messaggi: 19
Iscritto: 26/05/2011

Segnala al moderatore
Postato alle 14:10
Sabato, 18/02/2012
ragazzi sto cercando di creare una chat privata tra amici utilizzando il no-ip. nel primo client l'ho connesso al no-ip e anche il sever . solo che il problema consinte nel mandate messaggi/comandi utilizzando il no-ip.ho usato il seguente codice:
Codice sorgente - presumibilmente VB.NET

  1. Imports Microsoft.VisualBasic.ApplicationServices
  2. Imports System.Windows.Forms.VisualStyles.VisualStyleElement
  3.  
  4. Public Class no_ip
  5.  
  6.     Private Property User As String
  7.  
  8.     Private Property pass As String
  9.  
  10.     Private Property ip As String
  11.  
  12.     Private Property l As Object
  13.  
  14.     Private Property Status As Object
  15.  
  16.     Private Property t As Object
  17.  
  18.     Private Sub no_ip_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  19.  
  20.     End Sub
  21.  
  22.  
  23.     'routine for updating a No-IP service (www.no-ip.com)
  24.     Function UpdateNoIP(UserName, Password, Hostname, actIP)
  25.         Dim xmlhttp As Object
  26.         Dim URL As String
  27.  
  28.         xmlhttp = CreateObject("microsoft.xmlhttp")
  29.         URL = "http://dynupdate.no-ip.com/dns?username=" & UserName
  30.         URL = URL & "&password=" & Password & "&hostname=" & Hostname
  31.         If actIP <> "" Then URL = URL & "&ip=" & actIP
  32.  
  33.         xmlhttp.open("get", URL, False)
  34.         xmlhttp.SetRequestHeader("Pragma", "no-cache")
  35.         xmlhttp.SetRequestHeader("Cache-control", "no-cache")
  36.  
  37.         On Error Resume Next
  38.         xmlhttp.Send()
  39.  
  40.         If Err.Number <> 0 Then
  41.             UpdateNoIP = "Error!"
  42.             Exit Function
  43.         End If
  44.  
  45.         If xmlhttp.Status = 200 Then
  46.             UpdateNoIP = CStr(xmlhttp.responseText)
  47.         Else
  48.             If xmlhttp.Status = 401 Then
  49.                 UpdateNoIP = "Authorization Error"
  50.             Else
  51.                 UpdateNoIP = "Error"
  52.             End If
  53.         End If
  54.  
  55.         If InStr(UpdateNoIP, ":") Then
  56.             Status = AfterLast(UpdateNoIP, ":")
  57.             Status = BeforeLast(Status, Chr(10))
  58.             Select Case Status
  59.                 Case 0 : UpdateNoIP = "Success - IP address is current, no update performed"
  60.                 Case 1 : UpdateNoIP = "Success - DNS hostname update successful"
  61.                 Case 2 : UpdateNoIP = "Error - Hostname supplied does not exist"
  62.                 Case 3 : UpdateNoIP = "Error - Invalid username"
  63.                 Case 4 : UpdateNoIP = "Error - Invalid password"
  64.  
  65.                 Case 6 : UpdateNoIP = "Error - Account disabled due to violation of No-IP terms of service. Our terms of service can be viewed at http://www.no-ip.com/legal/tos"
  66.                 Case 7 : UpdateNoIP = "Error - Invalid IP. Invalid IP submitted is improperly formated, is a private LAN RFC 1918 address, or an abuse blacklisted address."
  67.                 Case 8 : UpdateNoIP = "Error - Disabled / Locked hostname"
  68.                 Case 9 : UpdateNoIP = "Host updated is configured as a web redirect and no update was performed."
  69.                 Case 10 : UpdateNoIP = "Error - Group supplied does not exist"
  70.                 Case 11 : UpdateNoIP = "Success - DNS group update is successful"
  71.                 Case 12 : UpdateNoIP = "Success - DNS group is current, no update performed."
  72.                 Case 13 : UpdateNoIP = "Error - Update client support not available for supplied hostname or group"
  73.                 Case 14 : UpdateNoIP = "Error - Hostname supplied does not have offline settings configured. Returned if sending offline=YES on a host that does not have any offline actions configured."
  74.                 Case 99 : UpdateNoIP = "Error - Client disabled. Client should exit and not perform any more updates without user intervention."
  75.                 Case 100 : UpdateNoIP = "Error - User input error usually returned if missing required request parameters"
  76.             End Select
  77.         End If
  78.     End Function
  79.  
  80.  
  81.     'public string functions
  82.     Function AfterLast(sFrom, sAfterLast)
  83.         If InStr(1, sFrom, sAfterLast) Then
  84.             AfterLast = Right(sFrom, Len(sFrom) - InStrRev(sFrom, sAfterLast) - (Len(sAfterLast) - 1))
  85.         Else
  86.             AfterLast = ""
  87.         End If
  88.     End Function
  89.  
  90.     Function BeforeLast(sIn, sLast)
  91.         t = AfterLast(sIn, sLast)
  92.         l = Len(sIn) - Len(t) - Len(sLast)
  93.         BeforeLast = Left(sIn, l)
  94.     End Function
  95.  
  96.     Private Function host() As Object
  97.         host = "xxx.no-ip.com"
  98.     End Function
  99.  
  100.     Private Function Left(sIn As Object, p2 As Object) As Object
  101.         Throw New NotImplementedException
  102.     End Function
  103.  
  104.     Private Function Right(sFrom As Object, p2 As Integer) As Object
  105.         Throw New NotImplementedException
  106.     End Function
  107.  
  108.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  109.         User = ""
  110.         pass = ""
  111.         ip = ""
  112.         TextBox4.Text = UpdateNoIP(User, pass, host, ip)
  113.     End Sub
  114. End Class


PM Quote