コード例 #1
0
/**
* @brief tcpserver thread
* @param void *arg :unused.
*/
static void tcpserver_thread(void *arg)
{
    tcpserv(arg);
    
    printf("Delete Tcpserver thread.\n");
    OSTaskDel(OS_PRIO_SELF);
}
コード例 #2
0
ファイル: init_thread.c プロジェクト: jeenter/CH-K-Lib
void init_thread(void* parameter)
{
	eth_system_device_init();
	lwip_system_init();
    
    dfs_init();
    elm_init();
    
    rt_hw_uart_init("uart0", 0);
    rt_console_set_device("uart0");
    rt_kprintf("rt-thread system start!\r\n");
    
    finsh_system_init();
    
    rt_hw_dflash_init("dflash0");
    dfs_mount("dflash0", "/", "elm", 0, 0);
    rt_hw_enet_phy_init();
    
    rt_kprintf("waitting for connection...");
    
    /* tcp server demo */
    extern void tcpserv(void* parameter);
    tcpserv(RT_NULL);
    
}
コード例 #3
0
ファイル: myfingered.c プロジェクト: Markeli/crypto
int main (int argc, char **argv)
{
	int ss, cs;
	struct sockaddr_in sin;
	int sinlen;
	char *message;
	int pid;
	/* This system call allows one to call fork without worrying about
	* calling wait. Don’t worry about what it means unless you start
	* caring about the exit status of forked processes, in which case
	* you should delete this line and read the manual pages for wait
	* and waitpid. For a description of what this signal call really
	* does, see the manual page for sigaction and look for
	* SA_NOCLDWAIT. Signal is an older signal interface which when
	* invoked this way is equivalent to setting SA_NOCLDWAIT. */
	//signal (SIGCHLD, SIG_IGN);
	printf("Server started\n");
	ss = tcpserv (PORT);
	if (ss < 0)
	exit (1);
	for (;;) 
	{
		sinlen = sizeof (sin);
		cs = accept (ss, (struct sockaddr *) &sin, &sinlen);
		if (cs < 0) 
		{
			perror ("accept");
			exit (1);
		}
		printf ("connection from %s\n", inet_ntoa (sin.sin_addr));
		printf("Getting message...\n");
		message = readline(cs);
		printf("Message was got.");
		printf("Client says:\n%s\n", message);
		if (write (cs, message, sizeof(message)) < 0) 
		{
			perror ("resend error");
			exit (1);
		}
		printf("Goodbye\n");
		close (cs);
	}
}