This commit is contained in:
yhy 2024-12-25 19:40:02 +08:00
parent c435b7c69a
commit fcd7eedf35
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,11 @@
#include "net_address.hpp"
#include "tcp_server.hpp"
#include <iostream>
using namespace std;
using namespace tinyrpc;
int main() {
TcpServer tcpServer(NetAddress(9001));
tcpServer.start();
return 0;
}

34
test/ipaddrtest/main.cc Normal file
View File

@ -0,0 +1,34 @@
#include <iostream>
#include <netinet/in.h>
using namespace std;
bool check(string ip){
int num_stat = 0; // 0-3
int dot_stat = 0; // 0-3
for(char ch : ip) {
if(std::isdigit(ch)) {
if(dot_stat < 0 || dot_stat > 3) {
return false;
}
num_stat += 1;
if(num_stat > 3) return false;
}else if(ch == '.'){
if(num_stat < 1 || num_stat > 3) {
return false;
}
dot_stat += 1;
num_stat = 0;
if(dot_stat > 3) return false;
} else {
return false;
}
}
return true;
}
int main() {
sockaddr_in addr{};
cout << addr.sin_addr.s_addr;
}