Die Function Returned 0 wenn ein Fehler auftritt oder die Accountdaten falsch sind. Wenn der Login klappt wird 1 zurückgegeben, wenn man „returnLimit“ auf True setzt bekommt man zusätzlich das Download-Limit mitgeteilt.
Imports System.Net.Sockets Imports System.IO Module Module1 Dim stream As NetworkStream Dim streamwrite As StreamWriter Dim streamread As StreamReader Dim NewsServer As String = "news.usenext.de" Dim Port As Integer = 119 Function UsenextCheck(ByVal user As String, ByVal pass As String, Optional ByVal returnLimit As Boolean = False) Try Dim Client As New TcpClient Client.Connect(NewsServer, Port) stream = Client.GetStream streamwrite = New StreamWriter(stream) streamread = New StreamReader(stream) Catch ex As Exception Return 0 Exit Function End Try streamread.ReadLine() client_send("AUTHINFO USER " & user) streamread.ReadLine() client_send("AUTHINFO PASS " & pass) Dim buffer As String = streamread.ReadLine() If Not buffer.StartsWith("281") Then Return 0 Exit Function End If If Not returnLimit = True Then Return 1 Else Dim str() As String = buffer.Split(":") Return "1 Traffic Left: " & CInt(CDbl(str(1).Remove(0, 1)) / 1048576) & " MB" End If End Function Sub client_send(ByVal text As String) streamwrite.WriteLine(text) streamwrite.Flush() End Sub Sub Main() MsgBox(UsenextCheck("avi-blabla-bla", "ummzummz_lul", True)) End Sub ' Sample by Sirect - Have Fun with it! No Limitations! :D End Module