Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.93 KB | None | 0 0
  1.     Private mail As String = Nothing
  2.     Private globalbuffer As String
  3.     Private buffer2 As String
  4.     Private line As String
  5.  
  6.     Public Function recv() As String
  7.         Try
  8.             Dim Data(4096) As Byte
  9.             sock.Receive(Data, 4096, Sockets.SocketFlags.None)
  10.             mail = System.Text.ASCIIEncoding.UTF8.GetString(Data)
  11.             globalbuffer = globalbuffer & mail
  12.         Catch ex As Exception
  13.             globalbuffer = "ERROR: " & ex.Message & vbCrLf
  14.         End Try
  15.  
  16.         While globalbuffer.Contains(vbCrLf)
  17.             line = globalbuffer.Substring(0, globalbuffer.Length - globalbuffer.IndexOf(vbCrLf))
  18.             'MsgBox("LINE IS:" & vbCrLf & line)
  19.             Clean(line)
  20.             globalbuffer = line.Substring(globalbuffer.IndexOf(vbCrLf) + 1)
  21.         End While
  22.  
  23.         Return buffer2
  24.         buffer2 = "" ' Reset for new input so that we don't copy already processed text
  25.     End Function
  26.  
  27.     Private Sub Clean(ByVal Target As String)
  28.         If Target.Contains("NOTICE AUTH") Then
  29.             Dim temp() As String = Nothing
  30.             temp = Target.Split(vbCrLf)
  31.             For i As Integer = LBound(temp) To UBound(temp)
  32.                 If temp(i).Contains("NOTICE AUTH") Then
  33.                     If Not temp(i).StartsWith(":") Then
  34.                         temp(i) = "(" & temp(i).Substring(2, temp(i).IndexOf(" N") - 2) & ") " & temp(i).Substring(temp(i).IndexOf(":*") + 1)
  35.                     Else
  36.                         temp(i) = "(" & temp(i).Substring(1, temp(i).IndexOf(" N") - 1) & ") " & temp(i).Substring(temp(i).IndexOf(":*") + 1)
  37.                     End If
  38.                 End If
  39.  
  40.                 buffer2 = buffer2 & temp(i) & vbCrLf
  41.  
  42.                 'If temp(i).Contains(vbCrLf) Then
  43.                 '    temp(i) = temp(i).Replace(vbCrLf, "\r\n")
  44.                 'End If
  45.                 'MsgBox("FROM ARRAY:" & vbCrLf & temp(i))
  46.             Next
  47.         End If
  48.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement