Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private mail As String = Nothing
- Private globalbuffer As String
- Private buffer2 As String
- Private line As String
- Public Function recv() As String
- Try
- Dim Data(4096) As Byte
- sock.Receive(Data, 4096, Sockets.SocketFlags.None)
- mail = System.Text.ASCIIEncoding.UTF8.GetString(Data)
- globalbuffer = globalbuffer & mail
- Catch ex As Exception
- globalbuffer = "ERROR: " & ex.Message & vbCrLf
- End Try
- While globalbuffer.Contains(vbCrLf)
- line = globalbuffer.Substring(0, globalbuffer.Length - globalbuffer.IndexOf(vbCrLf))
- 'MsgBox("LINE IS:" & vbCrLf & line)
- Clean(line)
- globalbuffer = line.Substring(globalbuffer.IndexOf(vbCrLf) + 1)
- End While
- Return buffer2
- buffer2 = "" ' Reset for new input so that we don't copy already processed text
- End Function
- Private Sub Clean(ByVal Target As String)
- If Target.Contains("NOTICE AUTH") Then
- Dim temp() As String = Nothing
- temp = Target.Split(vbCrLf)
- For i As Integer = LBound(temp) To UBound(temp)
- If temp(i).Contains("NOTICE AUTH") Then
- If Not temp(i).StartsWith(":") Then
- temp(i) = "(" & temp(i).Substring(2, temp(i).IndexOf(" N") - 2) & ") " & temp(i).Substring(temp(i).IndexOf(":*") + 1)
- Else
- temp(i) = "(" & temp(i).Substring(1, temp(i).IndexOf(" N") - 1) & ") " & temp(i).Substring(temp(i).IndexOf(":*") + 1)
- End If
- End If
- buffer2 = buffer2 & temp(i) & vbCrLf
- 'If temp(i).Contains(vbCrLf) Then
- ' temp(i) = temp(i).Replace(vbCrLf, "\r\n")
- 'End If
- 'MsgBox("FROM ARRAY:" & vbCrLf & temp(i))
- Next
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement