test
This commit is contained in:
parent
c435b7c69a
commit
fcd7eedf35
11
test/cor_reactortest/main.cc
Normal file
11
test/cor_reactortest/main.cc
Normal 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
34
test/ipaddrtest/main.cc
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user