473,385 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Email Sockets Question

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

Dec 5 '06 #1
1 1318
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)

iMaiden wrote:
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
Dec 5 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Madestro | last post by:
Hi guys, I am making a small program to retrieve e-mails from POP accounts. I got all the e-mail parsing stuff figured out, but I cannot seem to come up with a way to find out which e-mails are...
4
by: 0to60 | last post by:
I have a question about socket programming in general. Exactly what happens behind the scenes when I one socket connects to a different socket in listen mode? Using the dotnet framework, I...
13
by: joe215 | last post by:
I want my users to send emails from a Windows app that I am developing in Visual Basic.NET 2003. I found a good example of sending email to a SMTP server using the SmtpMail class. However, using...
17
by: Adam | last post by:
I need a console application to send me an e-mail....in the past I have use SQL Server's mail messaging to send my e-mails for console applications, but often the SQL Server mail message will not...
7
by: Bill English | last post by:
How do I send an object from one computer to another? -- I am a 14 year old C# developer, I am completely self taught, so please don't get mad if I ask a stupid question. Thanks.
5
by: VenuGopal | last post by:
Hi, My client uses Win 98. The email part does not work in Win98. I read the documentation and i find that System.Web is not supported in Win98. Now How do i send email on a win 98 platform....
2
by: ZorpiedoMan | last post by:
I'm new to the world of sockets, and this question is not VB specific: If multiple clients access the same server on the same port, and the server is set up to do some async communication, does...
3
by: derSchweiz | last post by:
Hi, Experimenting with sockets, and I think I got it half working. I have the following code: Private Sub socket_receive(ByVal sender As Object, ByVal e As System.EventArgs) Handles...
8
by: Mike Owen | last post by:
Hi, I am using the following code to send email on a Windows 2003 Web Server: Imports System.Net.Mail ........ Dim msgmail As New MailMessage msgmail.To.Add(New...
0
by: richard.charts | last post by:
Well, unfortunately, I couldn't get any answer on the msdn forums, so I'll give it a shot here. Real question at the bottom....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.