웹서브 Q

오젼·2022년 11월 24일
1

q1. client_socket - server_socket, request_message - response_message 이렇게 나누고 싶음.
이 때 request_message와 response_message를 socket class 에서 사용하는 게 나은지, webserv 클래스에서 선언하고 사용하는 게 나은지

q2. accept_socket을 server_socket class에 둘지 client_socket class에 둘지.

q3. nginx에선 설정파일에서 이미 bind failed면 서버 실행 못 함

https://github.dev/cclaude42/webserv

unsigned int	strToIp(std::string strIp) {
	size_t  sep = 0;
	unsigned int   n;
	unsigned char  m[4];
	size_t  start = 0;
	if (strIp == "localhost")
		strIp = "127.0.0.1";
	for (unsigned int i = 3 ; i != std::numeric_limits<uint32_t>::max(); i--) {
		sep = strIp.find_first_of('.', sep);
		std::string str = strIp.substr(start, sep);
		n = ft_atoi(str.c_str());
		m[i] = static_cast<unsigned char>(n);
		sep++;
		start = sep;
	}
	unsigned final = *(reinterpret_cast<unsigned int *>(m));
	return final;
}

0개의 댓글