Thanks alot for your help. I picked the Synchronous sample which
worked for me very well.
"Bryan Martin" <(E-Mail Removed)> wrote in message news:<uRe0LSL$(E-Mail Removed)>...
> http://msdn.microsoft.com/library/de...ketexample.asp
>
> Take special note to the manual reset event.
>
> Bryan Martin
>
> "Chris" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I took some samples from the net to help me create a TCP/IP socket
> > listener. I stripped out most of the code and put it below. Bottom
> > line is when I receive the ***END*** line from the client, the client
> > is done sending me data. Of course when this happens, my server
> > stops. I would like to know how to keep the server listening after
> > the client is done communicating. I'm sure most of the reason it stops
> > is that everything is in Sub Main. I did see some samples on
> > threading connections but I don't need that. Just one connection at a
> > time. This works perfectly otherwise.
> >
> > Thanks for help,
> >
> > Chris
> >
> > Imports System.Net.Sockets
> > Imports System.Net
> > Imports System.Net.WebProxy
> > Imports System.IO
> > Imports System
> > Imports System.Text.RegularExpressions
> > Class TCPSrv
> > Shared Sub Main()
> > Dim servermessage As String
> > Dim clientmessage As String
> > Const portNumber As Integer = 8100
> > Dim tcpListener As New TcpListener(portNumber)
> > tcpListener.Start()
> > Console.WriteLine("Waiting for connection...")
> > Dim socketforClient As Socket
> > socketforClient = tcpListener.AcceptSocket()
> > Dim NetworkStream As NetworkStream
> > networkStream = New NetworkStream(socketforClient)
> > Dim streamWriter As StreamWriter
> > streamWriter = New StreamWriter(NetworkStream)
> > Dim streamReader As StreamReader
> > streamReader = New StreamReader(NetworkStream)
> > Dim strPage As String
> >
> > Do While (Status)
> > If socketforClient.Connected Then
> > servermessage = streamReader.ReadLine()
> > If servermessage = "***END***" Then
> > Status = False
> > Exit Do
> > End If
> > clientmessage = "Response to the client"
> > streamWriter.WriteLine(clientmessage)
> > streamWriter.Flush()
> > End If
> > Console.WriteLine(servermessage)
> > streamWriter.Flush()
> >
> > Loop
> > End Sub
> > End Class