开发者

C# Socket Programming: Combining server and client into 1 solution

Currently im working on a facilitator application, competitor application and a chat server. Im using C# socket programming with winform.

It is to run 1 facilitator application and multiple competitor application connected to each other through the server.

Is there a way i can combine the server codes into the facilitator solution so that when i just run the facilitator the server is also launched together with the facilitator app.

Currentl开发者_Python百科y what im doing is to make the server into a .exe then then i run my facilitator application, it will alsp start the server.exe to launch the server.

public Facilitator()
    {
        Process.Start(@"C:\Users\Guest\Desktop\Server.exe");
        InitializeComponent();
    }

But just wondering if it is possible to incorporate it into just the facilitator app.

I referenced my chat server from this C# chat server guide and did my app based on this.

Your help will be appreciated. My apologies for my language if its a bit difficult to understand.


In case you want to debug both at the same time you can do this in Visual Studio like this.

Put the the client in one project and the server in another. Put both projects in the same solution. Right click on the solution name, pick "Set startup projects". Pick both projects and they will both start when you start debugging.


I believe it is far better to keep libraries and executables in separate solutions simply to enforce separation. In this case, your server has a different purpose than the facilitator. Keep those separate - they have different concerns.

In addition, since your facilitator depends on the server to function properly, I would move the start process to the Main method in your Program class. Ensure it is running then start facilitator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜