TimeNewRome 最近回复了
我个人猜测可能有以下原因:
1 、工作压力太大(可以换工作解决)
2 、水土不服(换个居住地)
3 、食物过敏(测过敏原)
4 、夫妻吵架(沟通解决,沟通不了换个伴侣)
花钱找个国服前十的大哥来跟孩子 1v1 。
要是大哥觉得孩子有天赋,自然就会给孩子推荐青训营。
要是大哥觉得孩子没天赋,不如趁早学一门手艺,出国工作多挣点钱。
请问 cursor 可以直接读路径下的文档,进而生成代码吗?
使用 perror 函数的输出结果是“Connect failed: Cannot assign requested address.”
以下是 server 端代码:
int main() {
int server_fd, new_socket;
struct sockaddr_in address;
int addrlen = sizeof(address);
char buffer[32768] = {0};
if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) == 0) {
perror("socket failed");
exit(EXIT_FAILURE);
}
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = htons(8091);
if (bind(server_fd, (struct sockaddr *)&address, sizeof(address)) < 0) {
perror("bind failed");
close(server_fd);
exit(EXIT_FAILURE);
}
if (listen(server_fd, 3) < 0) {
perror("listen");
close(server_fd);
exit(EXIT_FAILURE);
}
while (true) {
if ((new_socket = accept(server_fd, (struct sockaddr *)&address, (socklen_t*)&addrlen)) < 0) {
perror("accept");
close(server_fd);
exit(EXIT_FAILURE);
}
int valread = read(new_socket, buffer, 1024);
if (valread > 0) {
std::cout << buffer << std::endl;
memset(buffer, 0, sizeof(buffer));
}
close(new_socket);
}
close(server_fd);
return 0;
}
以下是 client 端代码:
void send(const std::string& message) {
int sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == -1) {
std::cerr << "Could not create socket" << std::endl;
return;
}
int sendBufferSize = 65536;
if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &sendBufferSize, sizeof(sendBufferSize)) < 0) {
std::cerr << "Could not set send buffer size" << std::endl;
close(sock);
return;
}
sockaddr_in server;
server.sin_addr.s_addr = inet_addr("10.130.9.6");
server.sin_family = AF_INET;
server.sin_port = htons(8091);
if (connect(sock, (struct sockaddr *)&server, sizeof(server)) < 0) {
std::cerr << "Connect failed. Error" << std::endl;
close(sock);
return;
}
if (send(sock, message.c_str(), message.length(), 0) < 0) {
std::cerr << "Send failed" << std::endl;
}
close(sock);
}