客户发送#include <iostream>
#include <string>
#include <limits>
#include <cmath>
#include <iomanip>
#include <fstream>
using namespace std;
int testScoreArray[100];
void selectSort(int testScoreArray[], int n);
void fileOutput(int testScoreArray[]);
int main()
{
int n = 100;
ifstream infile;
infile.open("testscoresarrayhomework.txt");
for (int i = 0; i < 100; i++) {
infile >> testScoreArray[i];
}
selectSort(testScoreArray, n);
fileOutput(testScoreArray);
infile.close();
return 0;
}
void selectSort(int testScoreArray[], int n)
{
//pos_min is short for position of min
int pos_min, temp;
for (int i = 0; i < n - 1; i++) {
pos_min = i; //set pos_min to the current index of array
for (int j = i + 1; j < n; j++) {
if (testScoreArray[j] < testScoreArray[pos_min])
pos_min = j;
//pos_min will keep track of the index that min is in, this is needed when a swap happens
}
//if pos_min no longer equals i than a smaller value must have been found, so a swap must occur
if (pos_min != i) {
temp = testScoreArray[i];
testScoreArray[i] = testScoreArray[pos_min];
testScoreArray[pos_min] = temp;
}
}
};
void fileOutput(int testScoreArray[])
{
ofstream outfile;
int gradeEvent = 0;
int previousGrade = 0;
outfile.open("testscoresoutput.txt");
outfile << "Test Score Breakdown: ";
outfile << endl
<< "Score / Occurance";
for (int i = 0; i < 100; i++) {
previousGrade = i;
if (previousGrade && previousGrade != i) {
outfile << '\n' << testScoreArray[i] << " / " << gradeEvent;
}
}
outfile.close();
};
与客户SYN
服务器isn
的服务器回复SYN ACK
如果超时,客户端会重新发送isn
当客户端发送数据时,它可以累积确认服务器的SYN
。
我尝试搜索,但找不到答案。
我知道tcp现在是如何设计的,我只是不知道为什么它的设计是这样的。为什么不能使用双向握手。
答案 0 :(得分:0)
根据定义,它不能使用双向握手。 TCP / IP被正式化为跨网络通信的标准(因特网工作)。具体而言,RFC 793要求:
“三次握手”是用于建立a的过程 连接。此过程通常由一个TCP和 另一个TCP回应了。如果有两个TCP,该过程也有效 同时启动程序。同时尝试时 发生时,每个TCP接收一个“SYN”段,它不携带 发送“SYN”后确认。当然,到来了 一个旧的重复“SYN”段可能会使它出现 收件人,同时连接启动正在进行中。 正确使用“重置”段可以消除这些情况的歧义。
如果您考虑协议的工作原理,您实际上并没有单一的全双工连接。相反,您有两个单工连接,每个连接都朝一个方向。这就是SYN
对SYN-ACK
的正确回复的原因。SYN
服务器通过发送始发者序列号作为确认号加1来确认同步请求;它同时尝试通过发送SYN
同步请求来打开自己与客户端的连接。
ACK
的正确答案始终为(?<name>...)
,即使连接失败也是如此。
关于发送重试的问题,是的;客户端将发送重试(通常最多三次,但实际上可能多达八次......没有定义限制)试图引出某种响应(最好是SYN-ACK,但可能是RST- ACK)。