Home All Groups Group Topic Archive Search About

tcpListener.AcceptSocket strange behavior

Author
11 Aug 2006 1:37 PM
Bjørn_Eliasen
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

Author
11 Aug 2006 2:16 PM
Cor Ligthert [MVP]
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" <s*@amcom.dk> schreef in bericht news:ueNcQtUvGHA.4756@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
Author
11 Aug 2006 2:37 PM
Bjørn_Eliasen
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]" <notmyfirstn***@planet.nl> skrev i en meddelelse news:u2ukGCVvGHA.4384@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" <s*@amcom.dk> schreef in bericht news:ueNcQtUvGHA.4756@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
Author
14 Aug 2006 1:36 AM
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?)

Show quoteHide quote
"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]" <notmyfirstn***@planet.nl> skrev i en meddelelse news:u2ukGCVvGHA.4384@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" <s*@amcom.dk> schreef in bericht news:ueNcQtUvGHA.4756@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