Home Forums Support Client and Server in the Same Application

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

    I have the need to be able to run NetworkComms Client and a Server in the same application.
    The way this works is I have a windows Form.

    The windows form creates and instance of ClassA.

    ClassA creates an instance of ClientAClass and ServerAClass.

    Within the ClientAClass and the ServerAClass I create an instance of either the NetworkComms Client or Server and Enable logging.
    ClientAClass creates client.log and the ServerAClass creates server.log

    However, what appears to be happening is whichever class is created 2nd in line, all of the logging ends up going to that file. So if server is created first all logging goes to server.log and visa versa.

    I started enabling logging because I am having an issue where my client randomly drops its connection and I am wondering if there is something similar going on and confusing the application.

    Can you shed some light on what might be going on. Is it possible to have the client and the server in the same application the way I do?

    #802
    Anonymous
    Inactive

    Heya GregJ,

    Logging is global, you can only ever have one instance of it in the same application domain.

    There is no need to make the distinction between client and server when using NetworkComms.Net. Every client immediately becomes a server when you start accepting incoming connections using:

    TCPConnection.StartListening(true);

    or

    UDPConnection.StartListening(true);

    What you are trying to do seems to be similar to our chat example, take a look at that, https://networkcomms.net/creating-a-wpf-chat-client-server-application/.

    Regards,
    Marc

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