Add Makefile, basic main
This commit is contained in:
parent
2b03969aa4
commit
c291ad1ec6
2 changed files with 48 additions and 3 deletions
17
Makefile
Normal file
17
Makefile
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
CXX=g++
|
||||||
|
CXXFLAGS=-Wall -Wextra -Werror -pedantic -std=c++14 -O2
|
||||||
|
CXXLIBS=-lpthread
|
||||||
|
|
||||||
|
OBJS = Bytes.o main.o protocol.o
|
||||||
|
TARGET = jeanhubert
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
$(TARGET): $(OBJS)
|
||||||
|
$(CXX) $(CXXLIBS) $(CXXFLAGS) $^ -o $@
|
||||||
|
|
||||||
|
%.o: %.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(OBJS) $(TARGET)
|
34
main.cpp
34
main.cpp
|
@ -4,10 +4,38 @@
|
||||||
* License: WTFPL v2 <http://www.wtfpl.net/>
|
* License: WTFPL v2 <http://www.wtfpl.net/>
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "nw_constants.h"
|
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
#include "protocol.h"
|
||||||
|
#include "nw_constants.h"
|
||||||
|
#include <cstring>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int /*argc*/, char** /*argv*/) {
|
||||||
//TODO read arguments
|
srand(time(NULL)+42);
|
||||||
|
|
||||||
|
SockAddr addr;
|
||||||
|
memset(&addr, 0, sizeof(addr));
|
||||||
|
addr.sin6_family = AF_INET6;
|
||||||
|
addr.sin6_port = csts::DEFAULT_PORT;
|
||||||
|
|
||||||
|
u64 myId=0;
|
||||||
|
for(int i=0; i < 8; i++) {
|
||||||
|
myId <<= 8;
|
||||||
|
myId += rand() % (1<<8);
|
||||||
|
}
|
||||||
|
|
||||||
|
SockAddr jch_addr;
|
||||||
|
memset(&jch_addr, 0, sizeof(jch_addr));
|
||||||
|
jch_addr.sin6_family = AF_INET6;
|
||||||
|
jch_addr.sin6_port = csts::DEFAULT_PORT;
|
||||||
|
if(inet_pton(AF_INET6, "::ffff::81.194.27.155", &jch_addr.sin6_addr)) {
|
||||||
|
perror("Cannot convert JCh address");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Protocol proto(addr, myId);
|
||||||
|
proto.sendEmpty(jch_addr);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue