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 apps and installs to complete.
A scannig of ports indicates that the port used (2000) is free.
The application has two threeads. The listener thread described above and an other thread for managing user interaction using the systray. The listener thread has initially loaded a form, which is hidden while waiting for new sockets to connect.
Here is a some of the code:
Dim ip As IPAddress
ip = IPAddress.Any
tcplistener = New TcpListener(ip, myPort)
tcpListener.Sta rt()
While True
Dim socket As Socket = tcpListener.Acc eptSocket()
Any suggestions will be appriciatd.
Bjørn 3 4365
Bjorn,
You can let your code run in a timerevent or you can let your thread sleep in the loop.
\\\\
threading.threa d.sleep(millise conds)
////
Now you are probably eating all your processor activitates in the loop.
I hope this helps,
Cor
"Bjørn Eliasen" <sp@amcom.dksch reef in bericht news:ue******** ******@TK2MSFTN GP04.phx.gbl...
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 apps and installs to complete.
A scannig of ports indicates that the port used (2000) is free.
The application has two threeads. The listener thread described above and an other thread for managing user interaction using the systray. The listener thread has initially loaded a form, which is hidden while waiting for new sockets to connect.
Here is a some of the code:
Dim ip As IPAddress
ip = IPAddress.Any
tcplistener = New TcpListener(ip, myPort)
tcpListener.Sta rt()
While True
Dim socket As Socket = tcpListener.Acc eptSocket()
Any suggestions will be appriciatd.
Bjørn
Thanks for the suggestion,
It is only a few specific programs which fails and the cpu is not busy at all. As I understand I have to wait for a socket to connect constantly otherwise I migth fail to get a connection?
The line "Dim socket As Socket = tcpListener.Acc eptSocket()" is just awaiting a new socket to connect and I can't really se how I can code any sleep functionality into this.
Bjørn
"Cor Ligthert [MVP]" <no************ @planet.nlskrev i en meddelelse news:u2******** ******@TK2MSFTN GP04.phx.gbl...
Bjorn,
You can let your code run in a timerevent or you can let your thread sleep in the loop.
\\\\
threading.threa d.sleep(millise conds)
////
Now you are probably eating all your processor activitates in the loop.
I hope this helps,
Cor
"Bjørn Eliasen" <sp@amcom.dksch reef in bericht news:ue******** ******@TK2MSFTN GP04.phx.gbl...
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 apps and installs to complete.
A scannig of ports indicates that the port used (2000) is free.
The application has two threeads. The listener thread described above and an other thread for managing user interaction using the systray. The listener thread has initially loaded a form, which is hidden while waiting for new sockets to connect.
Here is a some of the code:
Dim ip As IPAddress
ip = IPAddress.Any
tcplistener = New TcpListener(ip, myPort)
tcpListener.Sta rt()
While True
Dim socket As Socket = tcpListener.Acc eptSocket()
Any suggestions will be appriciatd.
Bjørn
Side talk:
Just wondering how can your client socket detect connection dropped by your
server socket?
(ie., when your tcpListener socket dropped, how can the other side of your
tcpClient socket know about it?)
"Bjørn Eliasen" wrote:
Thanks for the suggestion,
It is only a few specific programs which fails and the cpu is not busy at all. As I understand I have to wait for a socket to connect constantly otherwise I migth fail to get a connection?
The line "Dim socket As Socket = tcpListener.Acc eptSocket()" is just awaiting a new socket to connect and I can't really se how I can code any sleep functionality into this.
Bjørn
"Cor Ligthert [MVP]" <no************ @planet.nlskrev i en meddelelse news:u2******** ******@TK2MSFTN GP04.phx.gbl...
Bjorn,
You can let your code run in a timerevent or you can let your thread sleep in the loop.
\\\\
threading.threa d.sleep(millise conds)
////
Now you are probably eating all your processor activitates in the loop.
I hope this helps,
Cor
"Bjørn Eliasen" <sp@amcom.dksch reef in bericht news:ue******** ******@TK2MSFTN GP04.phx.gbl...
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 apps and installs to complete.
A scannig of ports indicates that the port used (2000) is free.
The application has two threeads. The listener thread described above and an other thread for managing user interaction using the systray. The listener thread has initially loaded a form, which is hidden while waiting for new sockets to connect.
Here is a some of the code:
Dim ip As IPAddress
ip = IPAddress.Any
tcplistener = New TcpListener(ip, myPort)
tcpListener.Sta rt()
While True
Dim socket As Socket = tcpListener.Acc eptSocket()
Any suggestions will be appriciatd.
Bjørn
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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: Coder |
last post by:
hi, i have a simple question; Suppose that followig code is a thread;
/***************************************************/
listener = new TcpListener( IP, PORT);
listener.Start();
while(running) {
|
by: Benny Raymond |
last post by:
Is it possible to get the ip address of the pc connecting to my
TcpListener? Here's how my code works so far:
listener = new TcpListener(_myIP, _port);
listener.Start();
// block until we get a connection
TcpClient client = listener.AcceptTcpClient();
// at this point I need to store the IP address for
|
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: 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: Darwin |
last post by:
Setting a server to listen on 8080 for incoming connections. Written in
VS2005 on a Multi-homed machine.
I get the warning:
Warning 1 'System.Net.Sockets.TcpListener.TcpListener(int)' is obsolete:
'This method has been deprecated. Please use TcpListener(IPAddress
localaddr, int port) instead.
on the code:
TcpListener tcpListener = new TcpListener(8080);
Do I really have to specify every IP address that I want to listen on?
|
by: aatif |
last post by:
I am working on a simple tcp server written in C#. The problem is that If I initialize it with local IP, it does not accept foreign connections (through static IP).
My PC has two IP's, local and static, how can I connect to it from some other location through static IP, as well as from within the LAN using local IP.
IPAddress ipAd = IPAddress.Parse("192.168.0.152");
TcpListener myList = new TcpListener(ipAd, 8089);
Console.WriteLine("The...
|
by: ethangk |
last post by:
Hey,
Im making an app in c#.net, i set up the listener, when it hits the while, it crashes. The code is straight from the ms example, modified a bit for a form instead of command line.
Heres the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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...
| |