This commit is contained in:
root 2011-06-21 13:42:30 +02:00
parent 5ef8d16c91
commit cc1a81a0c6

View file

@ -165,6 +165,7 @@ void* server_task(void* e)
serv_addr.sin_addr.s_addr = INADDR_ANY;
serv_addr.sin_port = htons(portno);
kprintf("binding");
/* Now bind the host address using bind() call.*/
if (bind(sockfd, (struct sockaddr *) &serv_addr,
sizeof(serv_addr)) < 0)
@ -176,10 +177,12 @@ void* server_task(void* e)
/* Now start listening for the clients, here process will
* go in sleep mode and will wait for the incoming connection
*/
kprintf("listening");
listen(sockfd,5);
clilen = sizeof(cli_addr);
/* Accept actual connection from the client */
kprintf("accepting");
newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr,
&clilen);
if (newsockfd < 0)
@ -189,6 +192,7 @@ void* server_task(void* e)
}
/* If connection is established then start communicating */
memset(buffer,0,256);
kpritnf("recieving");
n = read( newsockfd,buffer,255 );
if (n < 0)
{
@ -198,6 +202,7 @@ void* server_task(void* e)
kprintf("Here is the message: %s\n",buffer);
/* Write a response to the client */
kprintf("writing");
n = write(newsockfd,"I got your message",18);
if (n < 0)
{