Home Forums Support [PROBLEM] double TCPConnection

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #815
    Anonymous
    Inactive

    Hello again! I have encountered another problem. (Anyway, I don’t know if this is a bag or a feauture)

    When we use this code:
    `public TCPConnection Voice;
    public TCPConnection Pic;
    private void button1_Click(object sender, RoutedEventArgs e)
    {
    Voice = TCPConnection.GetConnection(new ConnectionInfo(“192.168.1.101”, 27017), new SendReceiveOptions<NullSerializer, QuickLZ>());
    Pic = TCPConnection.GetConnection(new ConnectionInfo(“192.168.1.101”, 27018), new SendReceiveOptions<NullSerializer, QuickLZ>());
    }`
    If we try to send object by TCPConnection Voice, the program throws exception: “Attempting to send packet on connection which has been closed or is currently closing.”

    Though, this code works correctly:

    public TCPConnection Voice;
    public TCPConnection Pic = TCPConnection.GetConnection(new ConnectionInfo("192.168.1.101", 27018), new SendReceiveOptions<NullSerializer, QuickLZ>());
    private void button1_Click(object sender, RoutedEventArgs e)
    {
    Voice = TCPConnection.GetConnection(new ConnectionInfo("192.168.1.101", 27017), new SendReceiveOptions<NullSerializer, QuickLZ>());
    }

    Apparently,when we open the second TCPConnection, the first connection closes.
    Am I doing something wrong or is this a bug?

    Thanks.

    #819
    Anonymous
    Inactive

    May I ask why are you trying to create or think you need a second connection?

    The way NetworkComms.Net is currently configured it is not possible to have more than one connection between 2 applications with identical IP addresses at both endpoints. What is possible is multiple connections over independent IP addresses/adaptors. This was done to help enforce connection integrity in the absence of any necessary use case. Once a connection has been created it is completely thread safe regardless of where/how it is used subsequently.

    This is why in the first example you gave the initial connection is automatically closed due to the creation of the second and also why the second example works.

    Regards,
    Marc

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.