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.Accept Socket()
sb.Socket.Begin Receive(sb.Buff er, 0, sb.Buffer.Lengt h, 0,
AddressOf ReceiveCallBack , sb)
Loop
End Sub
Private Sub ReceiveCallBack (ByVal ar As IAsyncResult)
Dim sb As SocketAndBuffer = CType(ar.AsyncS tate,
SocketAndBuffer )
Dim numbytes As Int32 = sb.Socket.EndRe ceive(ar)
Dim Receive As String = ASCII.GetString (sb.Buffer, 0, numbytes)
_count += 1
If _count = 1 Then sb.Socket.Send( "220 smtp.example.co m 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.Lengt h)
sb.Socket.Begin Receive(sb.Buff er, 0, sb.Buffer.Lengt h, 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
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.Accept Socket()
sb.Socket.Begin Receive(sb.Buff er, 0, sb.Buffer.Lengt h, 0,
AddressOf ReceiveCallBack , sb)
Loop
End Sub
Private Sub ReceiveCallBack (ByVal ar As IAsyncResult)
Dim sb As SocketAndBuffer = CType(ar.AsyncS tate,
SocketAndBuffer )
Dim numbytes As Int32 = sb.Socket.EndRe ceive(ar)
Dim Receive As String = ASCII.GetString (sb.Buffer, 0, numbytes)
_count += 1
If _count = 1 Then sb.Socket.Send( "220 smtp.example.co m 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.Lengt h)
sb.Socket.Begin Receive(sb.Buff er, 0, sb.Buffer.Lengt h, 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
Comment