473,385 Members | 1,492 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.

tcpListener.AcceptSocket strange behavior

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.Start()
While True
Dim socket As Socket = tcpListener.AcceptSocket()

Any suggestions will be appriciatd.

Bjørn
Aug 11 '06 #1
3 4341
Bjorn,

You can let your code run in a timerevent or you can let your thread sleep in the loop.
\\\\
threading.thread.sleep(milliseconds)
////

Now you are probably eating all your processor activitates in the loop.

I hope this helps,
Cor
"Bjørn Eliasen" <sp@amcom.dkschreef in bericht news:ue**************@TK2MSFTNGP04.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.Start()
While True
Dim socket As Socket = tcpListener.AcceptSocket()

Any suggestions will be appriciatd.

Bjørn
Aug 11 '06 #2
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.AcceptSocket()" 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**************@TK2MSFTNGP04.phx.gbl...
Bjorn,

You can let your code run in a timerevent or you can let your thread sleep in the loop.
\\\\
threading.thread.sleep(milliseconds)
////

Now you are probably eating all your processor activitates in the loop.

I hope this helps,
Cor
"Bjørn Eliasen" <sp@amcom.dkschreef in bericht news:ue**************@TK2MSFTNGP04.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.Start()
While True
Dim socket As Socket = tcpListener.AcceptSocket()

Any suggestions will be appriciatd.

Bjørn
Aug 11 '06 #3
Jck
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.AcceptSocket()" 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**************@TK2MSFTNGP04.phx.gbl...
Bjorn,

You can let your code run in a timerevent or you can let your thread sleep in the loop.
\\\\
threading.thread.sleep(milliseconds)
////

Now you are probably eating all your processor activitates in the loop.

I hope this helps,
Cor
"Bjørn Eliasen" <sp@amcom.dkschreef in bericht news:ue**************@TK2MSFTNGP04.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.Start()
While True
Dim socket As Socket = tcpListener.AcceptSocket()

Any suggestions will be appriciatd.

Bjørn
Aug 14 '06 #4

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

Similar topics

1
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...
4
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...
2
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(); ...
1
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...
2
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...
0
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...
1
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:...
1
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...
7
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...

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.