#include #include "serp.h" #include "p2tp.h" void callback (int fd, int event) { //p2tp_file* file = p2tp_meta(fd); printf("file %i: event\n",fd); } int main (int argc, const char * argv[]) { printf("Hello, World!\n"); p2tp_init(7001); int tf = p2tp_open("test_file",NULL); int tb = p2tp_open("test_file_copy",p2tp_file_info(tf)->hash_data); struct sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_port = htons(7001); addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); p2tp_add_peer(tb,addr,0); // TRICK: will open a channel to the first file /*p2tp_listen(tb,callback,P2TP_ANY_EVENT); while (!p2tp_file_info(tb)->complete) p2tp_loop();*/ //p2tp_dispatch(); p2tp_loop(0); p2tp_close(tb); p2tp_close(tf); return 0; }