0

currently I have a server and a client console application in c++ using winsock. In my situation the client is able to send a message to the server, which listens and it can aswer, but I need to make them to be able to always recieve and send messages to one another.

My problem is I can not use threads, I need to achieve this goal without them. How can this be done by sockets and loops? Any hint is welcome.

Thank you

4

1 回答 1

0

如果你不能使用线程,你必须在同一个循环中sendrecv。与其盲目地这样做,不如使用select函数来检查是否有任何来自任何套接字的传入消息,或者是否可以将数据写入(发送)到套接字。这是学习选择功能的参考。

于 2014-02-20T06:07:36.730 回答