客户端服务器应用程序中的CreateProcess() [英] CreateProcess() in a client server application

查看:71
本文介绍了客户端服务器应用程序中的CreateProcess()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,

我正在开发一个udp客户端 - 服务器应用程序,其中一个服务器应该可以处理40个客户端,这些客户端也可以同时登录...

现在在unix中这样的问题通过使用fork()函数来解决,它基本上创建了一个子进程来处理客户端并让服务器接受新的连接...

我在互联网上搜索,发现在Windows中没有fork()的确切类似,但是可以使用CreateProcess()...

我以前的研究也介绍了我到线程池所以现在我有两个问题:

1)我可以通过Windows中的CreateProcess()实现fork()的功能。

2)如果可行的话,我应该怎样做:线程池或创建多个进程?



期待响应......

hey,
I am working on a udp client-server application where one server is supposed to handle 40 clients which could all be logged on at once as well...
Now in "unix" such issues are resolved by using "fork()" function which basically creates a child process to deal with the client and leaves the server to accept new connections...
I searched on the internet and found out that an exact analogous of "fork()" is not available in windows, however "CreateProcess()" could be used...
My previous research also introduced me to "thread pool" so now I''ve two questions:
1)Could I acheive the functionality of "fork()" by "CreateProcess()" in windows.
2)if this is possible,what should I do go for: threadpool or creating multiple processes ?

looking forward to the response...

推荐答案

(1) CreateProcess fork 创建一个新进程。但是,fork会复制调用进程,而 CreateProcess 会启动可执行文件。这两个函数都允许实现多进程服务器。



(2)通常这样的服务器是多线程的,但是没有什么能阻止你使它成为多进程服务器。

请注意,进程间通信比较重。
(1) Both CreateProcess and fork creates a new process. However fork duplicates the calling process, while CreateProcess starts an executable. Both function allows the implementation of a multiprocess server.

(2) Usually such servers are multithreaded, however nothing prevents you to make it multiprocess instead.
Just be aware that inter-process communication is heavier.


这篇关于客户端服务器应用程序中的CreateProcess()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆