我一直在网上搜索有关C语言套接字的更多信息,但我无法找到我想要的内容。
所以这就是问题所在:
所以我的问题是:如何在每个子进程中更新数组,以便将同一个数组写入两个客户端?
我并不是真的在寻找任何示例代码或任何内容,而是更多关于此主题的概念性答案/更多资源。
谢谢!
答案 0 :(得分:0)
粗略的伪代码概念是
connectPlayers();
if(player1)
{
generateGame();
do
{
bytesSent = sendArray to other players
} while (!allBytesSent)
}
else
{
do
{
bytesRead = readArray from server
} while (!allBytesRead)
}
while(!gameComplete)
{
if(!firstTime through as player 1)
{
waitforyourTurn();
read and update Game State; //reads another players guess and update array
}
result = doAGuess();
sendGuess(result); //sends guess to other player
passTurnToNextPlayer();
}