473,326 Members | 2,805 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,326 software developers and data experts.

vb.net Sockets Problem

The following is a receive only SMTP server. It works fine but after
an unknown duration it just accepts connections and hangs. When this
happens I telnet into the server and it connects fine but also hangs.

Sub ListenToServer()

Dim LISTENING As Boolean
Dim localhostAddress As IPAddress =
ipAddress.Parse(ipAddress.ToString)

Dim oFile As System.IO.File
Dim oWrite As New System.IO.StreamWriter("c:/spam.txt", True)

Dim tcpList As New TcpListener(localhostAddress, 25)

LISTENING = True

Do While LISTENING
tcpList.Start()

Dim tcpCli As TcpClient = tcpList.AcceptTcpClient()
Dim ns As NetworkStream = tcpCli.GetStream
Dim sr As New StreamReader(ns)
Dim sw As New StreamWriter(ns)

sw.WriteLine("220 iMail SMTP server ready")
sw.Flush()
Dim receivedData As String = sr.ReadLine()
If InStr(LCase(receivedData), "ehlo") = 1 Or
InStr(LCase(receivedData), "helo") = 1 Then

sw.WriteLine("250 iMail Hello [71.105.78.90]")
Dim sender_email As String = sr.ReadLine()
sender_email = Trim(Replace(LCase(sender_email), "mail
from:", ""))
sw.WriteLine("250 " + sender_email + "....Sender OK")
sw.Flush()
Dim dest_email As String = sr.ReadLine()
dest_email = Trim(Replace(LCase(dest_email), "rcpt
to:", ""))
dest_email = Replace(dest_email, "<", "")
dest_email = Replace(dest_email, ">", "")

'MsgBox(dest_email)

sw.WriteLine("250 " + dest_email)
sw.Flush()
receivedData = sr.ReadLine()

sw.WriteLine("354 Start mail input; end with
<CRLF>.<CRLF>")
sw.Flush()
Dim c As Integer = 0
Do While receivedData <"." And Len(receivedData)
0
receivedData = sr.ReadLine()
sw.Flush()

Loop
sw.WriteLine("250 Queued mail for delivery")
sw.Flush()
End If

sr.Close()
sw.Close()
ns.Close()
tcpCli.Close()

Loop
tcpList.Stop()

End Sub

Any help is appreciated. TIA

Dec 7 '06 #1
0 776

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

Similar topics

4
by: Dr.Kadzija | last post by:
i have a client-server application. client and server should communicate via tcp sockets. ok, so i use Sockets, PrintWriter and BufferedReader. the problem is that: both client and server will send...
2
by: Tero Saarni | last post by:
Hi, I have several threads communicating with each other using events stored in Queues. Threads block on Queue.get() until somebody publishes an event in thread's event queue. I need to add...
0
by: Gonçalo Rodrigues | last post by:
Hi, I have a problem with threads and sockets. I'll try to describe the problem in words with pseudo-code. I've been working on a few classes to make it easier to work with threads. This...
1
by: Dmitry Akselrod | last post by:
Hello everyone, I have a vb.net application that wraps the TCPListener object in a class. The server connects to the local interface and establishes itself on port 9900. It then polls for...
0
by: mrpolitics | last post by:
So I'm working with PureIRCD (http://sourceforge.net/projects/pure-ircd) and everything was fine untill yesterday when the server crashed. So I did a cold restart and staretd the server back up...
14
by: jack | last post by:
At this link I have two c# projects, one is a client, the other is a server. Just point the ip address of the client at the server http://www.slip-angle.com/hosted/bug/ The server does...
15
by: mrpolitics | last post by:
So I'm working with PureIRCD (http://sourceforge.net/projects/pure-ircd) and everything was fine untill yesterday when the server crashed. So I did a cold restart and staretd the server back up...
3
by: J C | last post by:
Hi, I'm using UDPClient to make a simple DNS server. I notice that intermittently and unpredictibly I get: Unhandled Exception: System.Net.Sockets.SocketException: An existing connection...
5
by: Dan Ritchie | last post by:
I've got a client/server app that I used to send large amounts of data via UDP to the client. We use it in various scenarios, one of which includes rendering a media file on the client as it is...
0
by: rossabri | last post by:
This topic has been addressed in limited detail in other threads: "sockets don't play nice with new style classes :(" May 14 2005....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.