shell test
This commit is contained in:
parent
62713bc9d2
commit
b35dfc1bd8
1 changed files with 34 additions and 32 deletions
|
@ -183,12 +183,12 @@ void* server_task(void* e)
|
|||
Server srv;
|
||||
|
||||
server_init(&srv,5555,2);
|
||||
kprintf("created server");
|
||||
SHELLDEBUGPRINTF("created server\n");
|
||||
srv._OnRead = srv_on_read;
|
||||
srv._OnDisconnect = srv_on_disc;
|
||||
srv._OnConnect = srv_on_conn;
|
||||
sleep(5);
|
||||
kprintf("sending...");
|
||||
SHELLDEBUGPRINTF("sending...\n");
|
||||
srv_sendBuffer(&srv,0,"Hello you!",sizeof("Hello you!"));
|
||||
sleep(1);
|
||||
|
||||
|
@ -196,9 +196,9 @@ void* server_task(void* e)
|
|||
for (i = 0; i < 1024*4*4*4; i++)
|
||||
{
|
||||
if (srv_sendBuffer(&srv,0,buff,sizeof(buff))< 0)
|
||||
kprintf("dicker error!\n");
|
||||
SHELLDEBUGPRINTF("dicker error!\n");
|
||||
if (!(i%100))
|
||||
kprintf("\r-%d-",i);
|
||||
SHELLDEBUGPRINTF("\r-%d-",i);
|
||||
// Sleep(10);
|
||||
}
|
||||
tmp2 = get_clock_tick();
|
||||
|
@ -219,7 +219,7 @@ void* server_task(void* e)
|
|||
sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
kprintf("ERROR opening socket");
|
||||
SHELLDEBUGPRINTF("ERROR opening socket");
|
||||
return;
|
||||
}
|
||||
/* Initialize socket structure */
|
||||
|
@ -229,24 +229,24 @@ void* server_task(void* e)
|
|||
serv_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
serv_addr.sin_port = htons(portno);
|
||||
|
||||
kprintf("binding");
|
||||
SHELLDEBUGPRINTF("binding");
|
||||
/* Now bind the host address using bind() call.*/
|
||||
if (bind(sockfd, (struct sockaddr *) &serv_addr,
|
||||
sizeof(serv_addr)) < 0)
|
||||
{
|
||||
kprintf("ERROR on binding");
|
||||
SHELLDEBUGPRINTF("ERROR on binding");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Now start listening for the clients, here process will
|
||||
* go in sleep mode and will wait for the incoming connection
|
||||
*/
|
||||
kprintf("listening");
|
||||
SHELLDEBUGPRINTF("listening");
|
||||
listen(sockfd,5);
|
||||
clilen = sizeof(cli_addr);
|
||||
|
||||
/* Accept actual connection from the client */
|
||||
kprintf("accepting");
|
||||
SHELLDEBUGPRINTF("accepting");
|
||||
newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr,
|
||||
&clilen);
|
||||
if (newsockfd < 0)
|
||||
|
@ -256,21 +256,21 @@ void* server_task(void* e)
|
|||
}
|
||||
/* If connection is established then start communicating */
|
||||
memset(buffer,0,256);
|
||||
kprintf("recieving");
|
||||
SHELLDEBUGPRINTF("recieving");
|
||||
n = recv( newsockfd,buffer,255,0 );
|
||||
if (n < 0)
|
||||
{
|
||||
kprintf("ERROR reading from socket");
|
||||
SHELLDEBUGPRINTF("ERROR reading from socket");
|
||||
return;
|
||||
}
|
||||
kprintf("Here is the message: %s\n",buffer);
|
||||
SHELLDEBUGPRINTF("Here is the message: %s\n",buffer);
|
||||
|
||||
/* Write a response to the client */
|
||||
kprintf("writing");
|
||||
n = send(newsockfd,"I got your message",18,0);
|
||||
if (n < 0)
|
||||
{
|
||||
kprintf("ERROR writing to socket");
|
||||
SHELLDEBUGPRINTF("ERROR writing to socket");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -279,11 +279,11 @@ void* server_task(void* e)
|
|||
for (n = 0; n < 1024*256 ; n++)
|
||||
{
|
||||
if (!(n%100))
|
||||
kprintf("%d-",n);
|
||||
SHELLDEBUGPRINTF("%d-",n);
|
||||
err = send(newsockfd,buffer,sizeof(buffer),0);
|
||||
if (err < 0)
|
||||
{
|
||||
kprintf("error on sending: %d",err);
|
||||
SHELLDEBUGPRINTF("error on sending: %d",err);
|
||||
break;
|
||||
}
|
||||
// if (!(n%100))
|
||||
|
@ -293,7 +293,7 @@ void* server_task(void* e)
|
|||
|
||||
tmp2 = get_clock_tick();
|
||||
|
||||
kprintf("Send 1024*64 Bytes in : %d clock ticks",tmp2-tmp1);
|
||||
SHELLDEBUGPRINTF("Send 1024*256 Bytes in : %d clock ticks",tmp2-tmp1);
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
|
@ -414,29 +414,31 @@ int test_init(void)
|
|||
int i = 0;
|
||||
kprintf("start testing");
|
||||
|
||||
// if (!get_core_no())
|
||||
// create_kernel_task(NULL,server_task,NULL);
|
||||
// else
|
||||
// create_kernel_task(NULL,client_task,NULL);
|
||||
|
||||
|
||||
shell_init(get_core_no());
|
||||
|
||||
sleep(10);
|
||||
SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",get_core_no());
|
||||
|
||||
if (get_core_no())
|
||||
{
|
||||
sleep(5);
|
||||
shelldebugprint("sleeped 5 seconds\n");
|
||||
sleep(5);
|
||||
shelldebugprint("sleeped another 5 seconds\n");
|
||||
shelldebugprint("This is so wonderfull!\nEverything is so well formated.\n");
|
||||
// if (get_core_no())
|
||||
// {
|
||||
// sleep(5);
|
||||
// shelldebugprint("sleeped 5 seconds\n");
|
||||
// sleep(5);
|
||||
// shelldebugprint("sleeped another 5 seconds\n");
|
||||
// shelldebugprint("This is so wonderfull!\nEverything is so well formated.\n");
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
SHELLDEBUGPRINTF("for-Schleife-no: %d\n",i);
|
||||
}
|
||||
}
|
||||
// for (i = 0; i < 10; i++)
|
||||
// {
|
||||
// SHELLDEBUGPRINTF("for-Schleife-no: %d\n",i);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (!get_core_no())
|
||||
create_kernel_task(NULL,server_task,NULL);
|
||||
else
|
||||
create_kernel_task(NULL,client_task,NULL);
|
||||
|
||||
#if 0
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue