Email Sockets Question

  • Thread starter Thread starter iMaiden
  • Start date Start date
I

iMaiden

I am building a simple smtp server to receive email as follows:
Private Sub Listen()
Dim Listener As New TcpListener("25")
Dim sb As New SocketAndBuffer()
Listening = True
Listener.Start()
Do Until Listening = False

sb.Socket = Listener.AcceptSocket()
sb.Socket.BeginReceive(sb.Buffer, 0, sb.Buffer.Length, 0,
AddressOf ReceiveCallBack, sb)
Loop
End Sub

Private Sub ReceiveCallBack(ByVal ar As IAsyncResult)
Dim sb As SocketAndBuffer = CType(ar.AsyncState,
SocketAndBuffer)
Dim numbytes As Int32 = sb.Socket.EndReceive(ar)

Dim Receive As String = ASCII.GetString(sb.Buffer, 0, numbytes)
_count += 1

If _count = 1 Then sb.Socket.Send("220 smtp.example.com SMTP
server ready"*** this initial is the part I cannot figure out***)

MsgBox("receive" + Receive)
sb.Socket.Send(sb.Buffer)
Array.Clear(sb.Buffer, 0, sb.Buffer.Length)
sb.Socket.BeginReceive(sb.Buffer, 0, sb.Buffer.Length, 0,
AddressOf ReceiveCallBack, sb)

End Sub

I am able to telnet into my server and echo text but the server is not
able to send data to the client.
Any help is appreciated. TIA
 
Dim sr As New StreamReader(ns)
Dim returnedData As String = "220 smtp.sample.com SMTP
server ready"
Dim sw As New StreamWriter(ns)
sw.WriteLine(returnedData)
 
Back
Top