none
can i BeginAcceptTcpClient for more than once in TcpListener? RRS feed

  • Question

  • hi all, i am trying to write a tcp service with TcpListener. when i am trying to call TcpListener.BeginAcceptTcpClient for more than once, sometime, it will stuck, and no incoming connections can be generated.

    briefly my code looks like following,

    for i as int32 = 0 to 1

    listener.BeginAcceptTcpClient(addressof callback, nothing)

    end

    while my callback is simple like,

    dim c as TcpClient = listener.EndAcceptTcpClient(iar)

    it looks like when two callbacks fired together, it may fail, any hints?

    thank you.

    Friday, July 19, 2013 2:43 AM

All replies

  • bump

    Cheers, Amy

    Wednesday, July 24, 2013 8:16 AM
  • as far as i tried, it's not safe to BeginAcceptTcpClient / EndAcceptTcpClient more than once concurrently, i cannot make it clear which function breaks the internal status. when i tried to call then concurrently, no incoming connections can be generated any more. but i still ask for the help if anyone knows more about the implementation can give an explanation. since i also tried HttpListener, it can BeginGetContext / EndGetContext more than once.
    Wednesday, July 24, 2013 9:54 AM