Menu

Check for available connection first?

Help
2009-07-28
2013-05-20
  • Jeff Hedlund

    Jeff Hedlund - 2009-07-28

    To work around my problem in this post -> https://sourceforge.net/forum/message.php?msg_id=7531953

    I'm wondering, is there a way I can detect if there are any available ports to connect to before I attempt the connection?

    So I've got this running on the server:

      com2tcp-rfc2217.bat COM6 5555

    I connect with one client computer.

    With a second client computer, can I issue a command that tells me that the server already has 1 connection so I don't attempt another connection?

    Jeff

     
    • Jeff Hedlund

      Jeff Hedlund - 2009-07-28

      In addition to working around my other problem, this would let me possibly script something to tell the end user on the failing client computer "COM pool is at capacity"

      Jeff

       
    • Vyacheslav Frolov

      To the CVS version of hub4com added ability to set priority
      for listen ports. Now you can add a fake listen port with low
      priority and route it to simple server that will tell "All ports busy"
      and disconnect.

      See also:

      hub4com --help=tcp

       
    • Jeff Hedlund

      Jeff Hedlund - 2009-08-10

      Thanks very much for this, I am incorporating it now!

      Jeff

       
    • Jeff Hedlund

      Jeff Hedlund - 2009-08-11

      Vyacheslav,

      I have been playing with this by using the QUOTE server (RFC 865) that just returns a quote of the day and disconnects, and the hub4com client is not seeing the quote echo'd back to it. 

      Config looks like:

      ------------------------------------------
      COM3
      --use-driver=tcp
      *5555
      --bi-route=0:1

      5555/-1
      --bi-route=3:2
      127.0.0.1:17
      ------------------------------------------

      When I connect the 2nd client, the client sees some output from hub4com with this at the end:

      TCP(1) SEND: SB 44
        5 6 SE
      ReadOverlapped::StartRead(): ReadFileEx(778) TCP(1) ERROR Unknown error (64)

      On the server, I see this:

      TCP(2): Accept(778) = 740 from 192.168.50.10:3144
      Socket(0.0.0.0:0) = 730
      TCP(3): Connect(730, 127.0.0.1:17) ...
      TCP(3): Close(730) - OK
      TCP(2): Disconnect(740) - OK
      ReadOverlapped::OnRead(): TCP(2) ERROR Unknown error (64)
      ReadOverlapped::StartRead(): ReadFileEx(740) TCP(2) ERROR Unknown error (64)
      TCP(2): Close(740) - OK

      Any guidance?

      Thanks!
      Jeff

       
    • Vyacheslav Frolov

      Possible it's because the connection is reset before all data sent.
      Try to replace line 257 in plugins\tcp\comio.cpp

        if (shutdown(hSock, SD_BOTH) != 0)

      to

        if (shutdown(hSock, SD_SEND) != 0)

       
    • Jeff Hedlund

      Jeff Hedlund - 2009-08-14

      > Try to replace line 257 in plugins\tcp\comio.cpp

      > if (shutdown(hSock, SD_BOTH) != 0) 
      > to
      > if (shutdown(hSock, SD_SEND) != 0)

      Tried this and it resulted in an infinite loop trying to connect from the client.

      Jeff

       
    • Vyacheslav Frolov

      It's because of sign *

       

Log in to post a comment.