FogConnect
1.0.0
FogConnet adalah komponen yang mengintegrasikan koneksi, penjadwalan, transmisi dan fungsi lainnya dalam jaringan P2P.
<IP:Port>
yang digunakan untuk koneksi P2PFogConnect bergantung pada paket berikut:
Instal deps umum:
sudo apt-get install git make
Instal dependensi:
sudo apt-get install openssl libssl-dev libwebsockets-dev libjansson-dev libevent-dev libglib2.0-dev
make
Waktu pembuatan koneksi P2P rata-rata: 1,2~2 detik
Ubuntu 16.04.3 LTS
CPU Intel(R) Core(TM) i5-7500 @ 2,40GHz
Catatan: 7840 MB
#include "fog_connect.h"
char CRLF [ 2 ] = "rn" ;
void on_connect ( void * arg ) {
}
void on_recv ( void * arg ) {
fc_info * ud = ( fc_info * ) arg ;
size_t len = 0 ;
char * msg = evbuffer_readln ( ud -> buff , & len , EVBUFFER_EOL_CRLF );
if ( msg != NULL ) {
fc_send ( ud -> pr_connect , msg , len );
fc_send ( ud -> pr_connect , CRLF , sizeof ( CRLF ));
printf ( "sending: %sn" , msg );
fc_free ( msg );
}
}
void on_close ( void * arg ) {
}
int main () {
fc_setup ( "**:**:**:**:**:1c" );
fc_set_callback ( on_connect , on_recv , on_close );
getchar ();
fc_exit ();
return 0 ;
}
#include "fog_connect.h"
void on_connect ( void * arg ) {
fc_info * ud = ( fc_info * ) arg ;
char * msg = strdup ( "hellorn" );
fc_send ( ud -> pr_connect , msg , strlen ( msg ));
printf ( "sending: %sn" , msg );
fc_free ( msg );
}
void on_recv ( void * arg ) {
fc_info * ud = ( fc_info * ) arg ;
size_t len = 0 ;
char * msg = evbuffer_readln ( ud -> buff , & len , EVBUFFER_EOL_CRLF );
if ( msg != NULL ) {
printf ( "receiving: %sn" , msg );
fc_free ( msg );
fc_disconnect ( ud -> pr_connect );
}
}
void on_close ( void * arg ) {
}
int main () {
fc_setup ( "**:**:**:**:**:2c" );
fc_connect_peer ( "**:**:**:**:**:1c" , FOG_TRANSPORT_PROTOCOL_KCP , on_connect , on_recv , on_close );
getchar ();
fc_exit ();
return 0 ;
}