Email Sockets Question

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
 
I

iMaiden

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top