(Note: the TCP Client is on another machine, and attempts communication every
minute.)
Both apps use the same assembly
The service app starts thusly, creating the tcp object and starting the
timer in the OnStart event. The timer calls OpenServer (one time):
Public Class TCPService
Private tcp As SimpleTCP
Private Timer1 As Timer
Protected Overrides Sub OnStart(ByVal args() As String)
tcp = New SimpleTCP
Timer1 = New Timer(50)
AddHandler Timer1.Elapsed, New
System.Timers.E lapsedEventHand ler(AddressOf Timer1_Tick)
Timer1.Start()
End Sub
Protected Overrides Sub OnStop()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Tick(ByV al sender As System.Object, ByVal e As
System.Timers.E lapsedEventArgs )
Timer1.Enabled = False
tcp.OpenServer( Nothing)
End Sub
End Class
The win app is the same, really just a tester for the logic in the service,
except it creates the tcp object in form load and calls OpenServer in a
button click.
In the OpenServer method:
Server = New TcpListener(cfg .Port)
....
Try
Server.Start()
metrics.Log(Log NameServer, SourceNameServe r, "Server.Sta rt")
Running = True
While Running
If Server.Pending Then
metrics.Log(Log NameServer, SourceNameServe r,
"Server.Pending ")
Dim TalkThread As Thread = New Thread(TalkDela gate)
TalkThread.Star t()
End If
If Not (Respond Is Nothing) Then
Respond.Invoke( )
End If
End While
metrics.Log(Log NameServer, SourceNameServe r, "End While")
Catch ex As Exception
Dim S As String = ex.Message
metrics.Log(Log NameServer, SourceNameServe r, S)
End Try
I have confirmed that in OpenServer, both apps use the exact same values and
follow the exact same program flow. In the win app, it just plain works. In
the
service app (I do NOT have them running at the same time), Server.Pending is
always false, no matter how much data is waiting to be picked up. Running is
always true.
I considered that maybe I need the new constructor for TCPListener, so I used:
Server = New TcpListener(IPA ddress.Any, cfg.Port)
instead, but that made no difference.
Why would the server version simply fail to detect that data is pending?
Thanks,
Jon 4 3418
use a system threading timer and it wil work
hth
Michel
"Jon Jacobs" <Jo*******@disc ussions.microso ft.comschreef in bericht
news:4B******** *************** ***********@mic rosoft.com...
(Note: the TCP Client is on another machine, and attempts communication
every
minute.)
Both apps use the same assembly
The service app starts thusly, creating the tcp object and starting the
timer in the OnStart event. The timer calls OpenServer (one time):
Public Class TCPService
Private tcp As SimpleTCP
Private Timer1 As Timer
Protected Overrides Sub OnStart(ByVal args() As String)
tcp = New SimpleTCP
Timer1 = New Timer(50)
AddHandler Timer1.Elapsed, New
System.Timers.E lapsedEventHand ler(AddressOf Timer1_Tick)
Timer1.Start()
End Sub
Protected Overrides Sub OnStop()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Tick(ByV al sender As System.Object, ByVal e As
System.Timers.E lapsedEventArgs )
Timer1.Enabled = False
tcp.OpenServer( Nothing)
End Sub
End Class
The win app is the same, really just a tester for the logic in the
service,
except it creates the tcp object in form load and calls OpenServer in a
button click.
In the OpenServer method:
Server = New TcpListener(cfg .Port)
...
Try
Server.Start()
metrics.Log(Log NameServer, SourceNameServe r, "Server.Sta rt")
Running = True
While Running
If Server.Pending Then
metrics.Log(Log NameServer, SourceNameServe r,
"Server.Pending ")
Dim TalkThread As Thread = New Thread(TalkDela gate)
TalkThread.Star t()
End If
If Not (Respond Is Nothing) Then
Respond.Invoke( )
End If
End While
metrics.Log(Log NameServer, SourceNameServe r, "End While")
Catch ex As Exception
Dim S As String = ex.Message
metrics.Log(Log NameServer, SourceNameServe r, S)
End Try
I have confirmed that in OpenServer, both apps use the exact same values
and
follow the exact same program flow. In the win app, it just plain works.
In
the
service app (I do NOT have them running at the same time), Server.Pending
is
always false, no matter how much data is waiting to be picked up. Running
is
always true.
I considered that maybe I need the new constructor for TCPListener, so I
used:
Server = New TcpListener(IPA ddress.Any, cfg.Port)
instead, but that made no difference.
Why would the server version simply fail to detect that data is pending?
Thanks,
Jon
use a system threading timer and it wil work
Thanks but...
Sorry I didn't show this peice of code:
Imports System.Timers
The timer DOES fire.
The problem is that it DOES get to this code:
If Server.Pending Then
but Server.Pending is always FALSE no matter how much data is pending.
I've traced the code execution very carefully. The timer is not the issue.
Any idea why the listener is not listening right?
Thanks,
Jon
Make sure your service logs in with an account that has network access. The
default "LocalSyste m" account does not have network access.
Mike.
"Jon Jacobs" <Jo*******@disc ussions.microso ft.comwrote in message
news:BA******** *************** ***********@mic rosoft.com...
>use a system threading timer and it wil work
Thanks but...
Sorry I didn't show this peice of code:
Imports System.Timers
The timer DOES fire.
The problem is that it DOES get to this code:
If Server.Pending Then
but Server.Pending is always FALSE no matter how much data is pending.
I've traced the code execution very carefully. The timer is not the issue.
Any idea why the listener is not listening right?
Thanks,
Jon
Make sure your service logs in with an account that has network access. The
default "LocalSyste m" account does not have network access.
Thank you, Mike.
I tried it logging in with my user account, which for sure does have the
network access, the same account by which the win app version worked fine.
The service version does not work even then.
Jon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Keith Langer |
last post by:
I have a TCPListener which needs to listen on my LAN IP as well as the
loopback address. In VS.Net 2002 the TCPListener constructor could
accept the port as an argument and it automatically bound to all
network adapters (this is also how it worked with VB6). Now that
constructor is obsolete, and the new one requires an IPEndPoint or
IPAddress.
How could I listen on the same port on all network adapters using
VS.Net 2003? I'd rather...
|
by: byron guerrero |
last post by:
I need to execute a TcpListener in a windows service.
tanks for the help.
|
by: Doug Wyatt |
last post by:
So I'll preface this with the fact that I'm a UNIX developer by training and
have just recently gotten in to C# development on Windows. I'm basically
running in to a problem whereby I suspect something to do with process
groups or threads and closeOnExec semantics (to speak in POSIX terms) is
causing me a problem. I've got a windows service (let's call it
"myService") that, among other things, does :
onStart
creates a TcpListener on a...
|
by: Rob White |
last post by:
OK, so I have a TcpListener that is waiting for sockets, this piece of code:
IPAddress localAddress = Dns.GetHostByName(Dns.GetHostName()).AddressList;
IPEndPoint localEP = new IPEndPoint(localAddress, 9000);
TcpListener tcpListen = new TcpListener(localEP);
tcpListen.Start();
Socket skt = tcpListen.AcceptSocket();
.... do some socket stuff
skt.Close();
|
by: Dave Coate |
last post by:
Hi,
I am working on a client-server app. I can get two applications to talk to
each other on the same machine using 127.0.0.1, but as soon as I try it
using a computer name or actual IP address I get a SocketException: "No
connection could be made because the target machine actively refused it".
On the server I have a listener:
Private m_Listener As TcpListener
m_Listener = New TcpListener(IPAddress.Parse("127.0.0.1"), 8000)
| |
by: Terry Olsen |
last post by:
Hoping someone can help me here. I've got this code written, and it works
fine for the first connection. But if I connect another client (while the
first is still connected), I get connected but nothing else, no data
exchange. If I disconnect the 2nd session, I get a System.IO.IOException.
If I disconnect the first session with the 2nd session still connected, then
all the data I typed in the 2nd session gets returned to me as if it was...
|
by: bertymaes |
last post by:
Hi,
I'm using VB in VS2005 on a WXP SP2 machine to build a windows service
that listens to a port to accept messages. This solution works fine
when a connecting client sends a message, waits for an ACK and
disconnects. We now want the socket to remain OPEN after sending the
ACK, which it used to do on beta2 and older machines.
Does anyone know which property to set or another solution to keep the
socket open after the send.
|
by: Bjørn Eliasen |
last post by:
Hi,
I have an application running on all pc's in our company. Basically it is a TCPListener awaiting for sockets to connect and on connection performs the required tasks. The app works fine, but while the listener is awaiting for socket to connect several other applications can't start, and even installation of new applications migth hang. In order to finalise the other apps or installations the tcp listener is killed resulting in the other...
|
by: =?Utf-8?B?Sm9uIEphY29icw==?= |
last post by:
I use in vb (VS2005)
Server = New TcpListener(PortNumber)
Which is simple and straightforward. But I get
Public Sub New(port As Integer) is obsolete: This method has been
deprecated. Please use TcpListener(IPAddress localaddr, int port) instead.
It also gives a link that returns "page not found."
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |