示例#1
1
int main(int argc,char* argv[])
{
    int rc;

    /** caribou_init() must first be called before any other CARIBOU function calls */
	caribou_init(0);
	printf("** CARIBOU 0.9 STM32F407IGT6 DEMO **\n");
	network_init();
	caribou_exec();
}
示例#2
0
int main(int argc, char* argv[]) {
  int listenfd, connfd;
  struct sockaddr_in addr;
  char buf[256];
  time_t tick;

  network_init();

  listenfd = common_socket(AF_INET, SOCK_STREAM, 0);
  addr.sin_addr.s_addr = htonl(INADDR_ANY);
  addr.sin_family      = AF_INET;
  addr.sin_port        = htons(5555);
  common_bind(listenfd, (struct sockaddr*)&addr, sizeof(addr));
  common_listen(listenfd, 5);

  for (;;) {
    connfd = common_accept(listenfd, NULL, NULL);

    tick = time(NULL);
    snprintf(buf, sizeof(buf), "%.24s\r\n", ctime(&tick));
    common_write(connfd, buf, strlen(buf));

    common_close(connfd);
  }
  common_close(listenfd);

  network_destroy();

  return 0;
}
示例#3
0
//Main: we start here
int main(int argc, char **argv)
{
	printf("as3kinect server %s\n", _current_version);
	//waiting for client led status
	freenect_sync_set_led((freenect_led_options) 4, 0);
	//Listening to C-c
  	if (signal (SIGINT, clean_exit) == SIG_IGN)
    	signal (SIGINT, SIG_IGN);
	//Listening to C-z
	#ifndef _WIN32
  	if (signal (SIGTSTP, clean_exit) == SIG_IGN)
    	signal (SIGTSTP, SIG_IGN);
	#endif
	//Alloc memory for video and depth frames
	buf_depth_temp = malloc(FREENECT_DEPTH_11BIT);
	buf_rgb_temp = malloc(FREENECT_VIDEO_RGB);
	
	//Initialize network socket
	if ( network_init() < 0 )
		die = 1;
	
	//Sleep main process until exit
	while(!die)
		sleep(2);

	//making a clean exit
	free(buf_depth_temp);
	free(buf_rgb_temp);
	network_close();
	//device off led status
	freenect_sync_set_led((freenect_led_options) 0, 0);
	freenect_sync_stop();
	printf("\n[as3-server] cleanup done!\n");
	return 0;
}
示例#4
0
文件: main.c 项目: gapry/AOS
int main(void) {
    int result;

    dprintf(0, "\nSOS Starting...\n");

    _sos_init(&_sos_ipc_ep_cap, &_sos_interrupt_ep_cap);

    /* Initialise the network hardware */
    network_init(badge_irq_ep(_sos_interrupt_ep_cap, IRQ_BADGE_NETWORK));


    /* Initialize timer driver */
    result = start_timer(badge_irq_ep(_sos_interrupt_ep_cap, IRQ_BADGE_TIMER));
    conditional_panic(result != CLOCK_R_OK, "Failed to initialize timer\n");

    /* Init file system */
    _filesystem_init();
    //frametable_test(TEST_1 | TEST_2);

    /* Start the user application */
    //start_first_process(TTY_NAME, _sos_ipc_ep_cap);

    starting_first_process = true;
    proc_list_init();
    proc_create(TTY_NAME, strlen(TTY_NAME), _sos_ipc_ep_cap, first_process_created, NULL);

    dprintf(0, "\nSOS entering syscall loop\n");
    syscall_loop(_sos_ipc_ep_cap);
    return 0;
}
示例#5
0
int make_connection(const char *domain, const char *service)
{
	int network_status = network_init(domain, service);
	if (network_status)
		fprintf(stderr, "network error: %s\n", gai_strerror(network_status));
	return network_status;
}
示例#6
0
struct network *network_copy (struct network *net)
{
    struct channel *tmp;
    struct network *newnet = malloc(sizeof(struct network));

    network_init(newnet);

    if (net->name)
        newnet->name = strdup(net->name);
    if (net->url)
        newnet->url = strdup(net->url);

    newnet->portno = net->portno;

    if (net->nickname)
        newnet->nickname = strdup(net->nickname);
    if (net->realname)
        newnet->realname = strdup(net->realname);
    if (net->password)
        newnet->password = strdup(net->password);

    newnet->conf = net->conf;
    newnet->close_network = net->close_network;

    network_foreach_channel(net, tmp)
        network_add_channel(newnet, tmp->name);

    return newnet;
}
示例#7
0
文件: pxe.c 项目: emmericp/syslinux
/*
 * Initialize pxe fs
 *
 */
static int pxe_fs_init(struct fs_info *fs)
{
    (void)fs;    /* drop the compile warning message */

    /* Prepare for handling pxe interrupts */
    pxe_init_isr();

    /* This block size is actually arbitrary... */
    fs->sector_shift = fs->block_shift = TFTP_BLOCKSIZE_LG2;
    fs->sector_size  = fs->block_size  = 1 << TFTP_BLOCKSIZE_LG2;

    /* Find the PXE stack */
    if (pxe_init(false))
	kaboom();

    /* See if we also have a gPXE stack */
    gpxe_init();

    /* Network-specific initialization */
    network_init();

    /* Initialize network-card-specific idle handling */
    pxe_idle_init();

    /* Our name for the root */
    strcpy(fs->cwd_name, "::");

    return 0;
}
示例#8
0
文件: main.c 项目: cfrost/buenos
void init_startup_thread(uint32_t arg)
{
    /* Threads have arguments for functions they run, we don't
       need any. Silence the compiler warning by using the argument. */
    arg = arg;
    process_id_t pid;

    kprintf("Mounting filesystems\n");
    vfs_mount_all();

    kprintf("Initializing networking\n");
    network_init();

    if(bootargs_get("initprog") == NULL) {
	kprintf("No initial program (initprog), dropping to fallback\n");
	init_startup_fallback();
    }

    kprintf("Starting initial program '%s'\n", bootargs_get("initprog"));

    pid = process_spawn(bootargs_get("initprog"));
    if (pid < 0)
        KERNEL_PANIC("Couldn't fit initial program in process table.\n");

    process_join(pid);
    halt_kernel();
}
示例#9
0
int main(int argc, char* argv[])
{
	if(argc!=3) { print_usage(); exit(0); }
	if(sock_str2addr(argv[2], &sa)==NULL) { print_usage(); exit(0); }

	if(strcmp(argv[1], "client")!=0 && strcmp(argv[1], "server")!=0) { print_usage(); exit(0); }

	sock_init();
	fdwatch_init();
	mempool_init();
	threadpool_init(1);
	network_init(20000);

	if(strcmp(argv[1], "client")==0) {
		client_do();
	} else {
		server_do();
	}

	network_final();
	threadpool_final();
	mempool_final();
	fdwatch_final();
	sock_final();

	return 0;
}
示例#10
0
static void ICACHE_FLASH_ATTR networkTimeFoundCb(const char *name, ip_addr_t *ip, void *arg) {
  static esp_tcp tcp;
  struct espconn *conn=(struct espconn *)arg;
  if (ip==NULL) {
    os_printf("Nslookup failed :/ Trying again...\n");
    os_printf("lfai");
    network_init();
  }

  // os_printf("lokk"); 
  char page_buffer[20];
  os_sprintf(page_buffer,"DST: %d.%d.%d.%d",
  *((uint8 *)&ip->addr), *((uint8 *)&ip->addr + 1),
  *((uint8 *)&ip->addr + 2), *((uint8 *)&ip->addr + 3));
  os_printf(page_buffer);  

  // conn->type=ESPCONN_TCP;
  // conn->state=ESPCONN_NONE;
  // conn->proto.tcp=&tcp;
  // conn->proto.tcp->local_port=espconn_port();
  // conn->proto.tcp->remote_port=80;
  // os_memcpy(conn->proto.tcp->remote_ip, &ip->addr, 4);
  // espconn_regist_connectcb(conn, networkConnectedCb);
  // espconn_regist_disconcb(conn, networkDisconCb);
  // espconn_regist_reconcb(conn, networkReconCb);
  // espconn_regist_recvcb(conn, networkRecvCb);
  // espconn_regist_sentcb(conn, networkSentCb);
  // espconn_connect(conn);

}
示例#11
0
int daemon_main()
{
	network_init(); // (WSAStartup())
	register_signals();
	sdns::conf.read_config();
	try {
		tcp_thread tcp;
		eventloop eloop(&tcp);
		tcp.set_pointers(&eloop);
		if(sdns::conf[sdns::SDNS_USER] != "")
			drop_root(sdns::conf[sdns::SDNS_USER]);
		else
			dout() << "SDNS_USER not set, not changing uid/gid";
		std::thread eventloop_th(std::ref(eloop));
		std::thread tcp_th(std::ref(tcp));
		while(true) {
			os_event event = wait_for_os_event();
			if(event == os_event::shutdown) break;
			if(event == os_event::reload) eloop.reread_static_records();
		}
		eloop.stop();
		tcp.stop();
		eventloop_th.join();
		tcp_th.join();
	} catch(const e_exception &e) {
		eout() << "Error at main(): " << e;
		eout() << "errno was: " << errno << ": " << strerror_rp(errno);
		return EXIT_FAILURE;
	}
	return EXIT_SUCCESS;
}
示例#12
0
int main() {
	network_init();

	float_run_tests();

	network_shutdown();
}
示例#13
0
int main(int argc, char* argv[]) {
  int listenfd;
  int clientfd;
  struct sockaddr_in addr;
  socklen_t addrlen;

  network_init();

  listenfd = common_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  addr.sin_addr.s_addr = htonl(INADDR_ANY);
  addr.sin_family      = AF_INET;
  addr.sin_port        = htons(5555);
  common_bind(listenfd, (struct sockaddr*)&addr, sizeof(addr));
  common_listen(listenfd, SOMAXCONN);

  printf("echo server start sucess !!!\n");
  for (;;) {
    addrlen = sizeof(addr);
    clientfd = common_accept(listenfd, (struct sockaddr*)&addr, &addrlen);

    CreateThread(NULL, 0, echo_process, &clientfd, 0, NULL);
  }
  common_close(listenfd);

  network_destroy();

  return 0;
}
示例#14
0
文件: main.c 项目: mrb852/osm
void init_startup_thread(uint32_t arg)
{
    /* Threads have arguments for functions they run, we don't
       need any. Silence the compiler warning by using the argument. */
    arg = arg;

    kprintf("Mounting filesystems\n");
    vfs_mount_all();

    kprintf("Initializing networking\n");
    network_init();

    if(bootargs_get("initprog") == NULL) {
        kprintf("No initial program (initprog), dropping to fallback\n");
        init_startup_fallback();
    }

    kprintf("Starting initial program '%s'\n", bootargs_get("initprog"));

    /* `process_start` no longer takes an executable as its argument, so we need
       to start initprog with `process_spawn`. */
    process_id_t pid = process_spawn(bootargs_get("initprog"));
    if (pid < 0) {
        KERNEL_PANIC("Couldn't fit initial program in process table.\n");
    }
    process_join(pid);

    /* The current process_start() should never return. */
    KERNEL_PANIC("Run out of initprog.\n");
}
示例#15
0
文件: main.c 项目: ConvTeam/FWlib-dev
int32 main(void)
{
	if(platform_init(NULL) != RET_OK) 
		goto FAIL_TRAP;

	if(network_init(ASSIST_SOCK, NULL, NULL) != RET_OK) {
		ERR("network_init fail");
		goto FAIL_TRAP;
	}

	NL1;
	LOG("-----------------------------------");
	LOG("Serial to Ethernet Using AT Command");
	LOG("-----------------------------------");
	NL2;

	atc_init();
	alarm_set(2000, dhcp_trigger, 0);	//dhcp_auto_start();

	while(1) {
		atc_run();
		alarm_run();
		sockwatch_run();
		wizpf_led_flicker(WIZ_LED1, 1000);	// check loop is running
	}

FAIL_TRAP:
	wizpf_led_trap(1);
	return 0;
}
示例#16
0
int engine_init(struct engine *engine, knot_mm_t *pool)
{
	if (engine == NULL) {
		return kr_error(EINVAL);
	}

	memset(engine, 0, sizeof(*engine));
	engine->pool = pool;

	/* Initialize state */
	int ret = init_state(engine);
	if (ret != 0) {
		engine_deinit(engine);
	}
	/* Initialize resolver */
	ret = init_resolver(engine);
	if (ret != 0) {
		engine_deinit(engine);
		return ret;
	}
	/* Initialize network */
	network_init(&engine->net, uv_default_loop());

	return ret;
}
示例#17
0
void retro_init(void)
{
   frame_buf = (uint16_t*)calloc(320 * 240, sizeof(uint16_t));
   //Initialise winsock
   log_cb(RETRO_LOG_INFO, "Initialising sockets\n");
   network_init();
}
void ICACHE_FLASH_ATTR networkDisconCb(void *arg) 
{
  //uart0_tx_buffer("dcon",4);
  // Thank to [email protected]
  os_timer_disarm(&network_timer);
  os_delay_us(20000000); //20000ms = 20sec!
  network_init();
}
示例#19
0
int main(int argc, char **argv)
{
	if ( network_init() < 0 )
		return -1;
	
	while(!die);

	return 0;
}
示例#20
0
文件: main.c 项目: ConvTeam/FWlib-dev
int32 main(void)
{
    // Platform Initialization
	if(platform_init(NULL) != RET_OK) 
		goto FAIL_TRAP;
    
    // Network Initialization
	if(network_init(0, NULL, NULL) != RET_OK) {
		ERR("network_init fail");
		goto FAIL_TRAP;
	}
    
	NL1;
	LOG("-----------------------------------");
	LOG(" WIZlib Project - SNTP Example     ");
	LOG("-----------------------------------");
	NL2;
	
	// ToDo: Modules Initialization
	// Ex) dhcp_auto_start();
	//     atc_init();  
    
    // NTP Initialization   
    set_ntp_default();
    set_ntp_client_msg(TIMESERVER1);
        
    Delay_tick(2000);	// prevent first send fail
    
    LOG(">>> SNTP Example Start >>>");
    
    // Serial Terminal Menu Initialization
    {
        menu_init();	    	
        menu_add("NTP : Display Time Info", 0, mn_disp_ntp);
        menu_add("NTP : Get Time Data from Timeserver", 0, mn_get_timedata);    
    }
    
	while(1) {
	
		// ToDo: Modules Run
		// Ex) atc_run();
		//     alarm_run();
		//     sockwatch_run();
        
        // Configuration menu
        alarm_run();
        menu_run();
        
        //LOGF(".");

		wizpf_led_flicker(WIZ_LED1, 1000);	// check loop is running
	}

FAIL_TRAP:
	wizpf_led_trap(1);
	return 0;
}
示例#21
0
int main()
{
	struct sockaddr_in peeraddr;
	socklen_t addrlen;
	pid_t pid;
	
	sockfd = network_init();
	if (-1 == pipe(pipefd))
		error_exit("pipe");
	mesgbuff = (mesgpack_st *)malloc(sizeof(mesgpack_st));
	userlist = (linknode_st *)malloc(sizeof(linknode_st));
	userlist->next = NULL;

	
	if (-1 == (pid = fork()))
		error_exit("fork");
	/* ============== child, process client message ===============*/
	if (0 == pid) {
		close(pipefd[1]);
		signal(SIGUSR1, sigusr1_handler);
		while (1) {
			if( 0 >= recvfrom(sockfd, mesgbuff, sizeof(mesgpack_st),0, 
						(struct sockaddr *)&peeraddr, &addrlen))
				perror("child:recvfrom");
	
			printf("[%d]%s:%d\n", addrlen, 
					inet_ntoa(peeraddr.sin_addr), ntohs(peeraddr.sin_port));

			switch (mesgbuff->type) {
			case CMD_CHAT:
				broadcast(sockfd, userlist, mesgbuff);
				break;
			case CMD_LOGIN:
				user_login(sockfd, userlist, (struct sockaddr *)&peeraddr, mesgbuff);
				break;
			case CMD_LOGOUT:
				user_logout(sockfd, userlist, (struct sockaddr *)&peeraddr, mesgbuff);
				break;
			default:
				break;
			}
		}
	} else {
	/* ================ father process local data ============= */
		close(pipefd[0]);
		strcpy(mesgbuff->user, "system");
		setbuf(stdout, NULL);
		
		while (1) {
			printf(">");
			fgets(mesgbuff->data, DATA_BUFF_LEN, stdin);
			write(pipefd[1], mesgbuff->data, DATA_BUFF_LEN);
			kill(pid, SIGUSR1);
		}
	}
	return 0;
}	
示例#22
0
文件: main.c 项目: seablueg/FWlib-dev
int32 main(void)
{
#define TCP_LISTEN_PORT	5000
#define UDP_LISTEN_PORT	5000

	int8 ret, root;
	uint32 tick = 0;

	ret = platform_init();
	if(ret != RET_OK) {
		goto FAIL_TRAP;
	}

	ret = network_init(SOCK_DHCP, NULL, NULL);
	if(ret != RET_OK) {
		ERRA("network_init fail - ret(%d)", ret);
		goto FAIL_TRAP;
	}

	printf("\r\n-----------------------------------\r\n");
	printf("SMTP Client using W5200\r\n");
	printf("-----------------------------------\r\n\r\n");

	Delay_tick(2000);

	menu_init();
	root = menu_add("Network setting", 0, NULL);
	menu_add("Show", root, mn_show_network);
	menu_add("Static Set", root, mn_set_network);
	menu_add("Loopback", 0, mn_loopback);
	menu_add("LED Test", 0, mn_set_led);
	root = menu_add("App Test", 0, NULL);
	menu_add("DNS", root, mn_dns);
	menu_add("BASE64", root, mn_base64);
	menu_add("eMail", root, mn_email);
	menu_print_tree();

	dhcp_alarm_start(NULL);

	while(1) {

		alarm_run();
		menu_run();

		if(lb_tcp) loopback_tcps(7, (uint16)TCP_LISTEN_PORT);
		if(lb_udp) loopback_udp(7, (uint16)UDP_LISTEN_PORT);

		if(wizpf_tick_elapse(tick) > 1000) {	// running check
			wizpf_led_set(WIZ_LED3, VAL_TOG);
			tick = wizpf_get_systick();
		}
	}

FAIL_TRAP:
	wizpf_led_trap(1);
	return 0;
}
示例#23
0
void http_thread() {
	screenshot_buffer = malloc(SCREEN_BUFFER_SIZE);
	network_init();
	network_print_config();
	httpd_start();
	while(1) {
		network_poll();
	}
}
示例#24
0
int libnet_init(struct libnet_config *pcfg)
{
	libnet_cb = pcfg->cb;
#ifndef LIB_W5300
	return network_init(pcfg);
#else
	return 0;
#endif	
}
示例#25
0
static bool init_socket(netplay_t *netplay, const char *server, uint16_t port)
{
   if (!network_init())
      return false;

   if (!init_tcp_socket(netplay, server, port, netplay->spectate.enabled))
      return false;

   return true;
}
示例#26
0
void ICACHE_FLASH_ATTR user_init(void)
{  
    uart_div_modify(0, UART_CLK_FREQ / 115200);
    gpio_user_init();

    printf("SDK version:%s\n", system_get_sdk_version());

    //init_blinking_led();

    network_init();
}
示例#27
0
int main(int argc, char **argv)
{
	signal(SIGPIPE,handle_sig);
	g_set_application_name("Camera Test - By Feesh! (A lot of code borrowed from Sonicsnap-gui-1.7)");
	gtk_init(&argc, &argv);
	
	if(argc>1)
		network_init(argv[1]);	
	else
		network_init("localhost");
	
	if(argc>2)
		camera_open(argv[2],WIDTH, HEIGHT);
	else
		camera_open("/dev/video0",WIDTH, HEIGHT);
	gui_init();
	
	gtk_main();
	return 0;
}
示例#28
0
static int net_http_new_socket(const char *domain, int port)
{
   int fd;
#ifndef _WIN32
#ifndef VITA
   struct timeval timeout;
#endif
#endif
   struct addrinfo hints, *addr = NULL;
   char portstr[16] = {0};
   
   /* Initialize the network. */
   if (!network_init())
      return -1;

   snprintf(portstr, sizeof(portstr), "%i", port);

   memset(&hints, 0, sizeof(hints));
   hints.ai_family   = AF_UNSPEC;
   hints.ai_socktype = SOCK_STREAM;
   hints.ai_flags    = 0;
   
   if (getaddrinfo_retro(domain, portstr, &hints, &addr) < 0)
      return -1;
   if (!addr)
      return -1;

   fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);

#ifndef _WIN32
#ifndef VITA
   timeout.tv_sec=4;
   timeout.tv_usec=0;
   setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof timeout);
#endif
#endif
   if (connect(fd, addr->ai_addr, addr->ai_addrlen) != 0)
   {
      freeaddrinfo_retro(addr);
      socket_close(fd);
      return -1;
   }

   freeaddrinfo_retro(addr);

   if (!socket_nonblock(fd))
   {
      socket_close(fd);
      return -1;
   }

   return fd;
}
示例#29
0
/*
* BEE::net_init() - Initialize the networking utilities
*/
int BEE::net_init() {
    if (!options->is_network_enabled) {
        return 1; // Return 1 if networking is disabled
    }

    if (network_init()) { // Attempt to initialize networking
        return 2; // Return 2 on failure to init
    }
    net->is_initialized = true; // Mark the network as ready

    return 0; // Return 0 on success
}
示例#30
0
static bool remote_init_network(rarch_remote_t *handle,
      uint16_t port, unsigned user)
{
   struct addrinfo hints = {0};
   char port_buf[16]     = {0};
   struct addrinfo *res  = NULL;
   int yes               = 1;

   port = port + user;

   if (!network_init())
      return false;

   RARCH_LOG("Bringing up remote interface on port %hu.\n",
         (unsigned short)port);

#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY)
   hints.ai_family   = AF_INET;
#else
   hints.ai_family   = AF_UNSPEC;
#endif
   hints.ai_socktype = SOCK_DGRAM;
   hints.ai_flags    = AI_PASSIVE;


   snprintf(port_buf, sizeof(port_buf), "%hu", (unsigned short)port);
   if (getaddrinfo_retro(NULL, port_buf, &hints, &res) < 0)
      goto error;

   handle->net_fd[user] = socket(res->ai_family,
         res->ai_socktype, res->ai_protocol);
   if (handle->net_fd[user] < 0)
      goto error;

   if (!socket_nonblock(handle->net_fd[user]))
      goto error;

   setsockopt(handle->net_fd[user], SOL_SOCKET,
         SO_REUSEADDR, (const char*)&yes, sizeof(int));
   if (bind(handle->net_fd[user], res->ai_addr, res->ai_addrlen) < 0)
   {
      RARCH_ERR("Failed to bind socket.\n");
      goto error;
   }

   freeaddrinfo_retro(res);
   return true;

error:
   if (res)
      freeaddrinfo_retro(res);
   return false;
}