telnet server creating PART: out of blocks error

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

telnet server creating PART: out of blocks error

Jump to solution
724 Views
dnappier
Contributor I

I have made a simple telnet server that accepts a connection and sends the stream socket to a new thread. It works great with one connection but the second will accept the connection and then die.

 

When I pause the program and look at the server task summary it show PART: Out of Blocks error. Does anyone know what this and how do I fix it? I am not doing any partitioning myself.

 

The code is below

 

/*
* telnet_server.c
*
* Created on: Jan 11, 2012
* Author: Doug Nappier
*/

#include "telnet_server.h"

void telnet_server(uint_8 parameters)
{
uint_32 sock,listensock;
sockaddr_in blue_box_addr;
uint_32 error = 256;
char str[] = "\n Connected to Blue Box \n";

listensock = socket(PF_INET, SOCK_STREAM, 0);
setsockopt(listensock, SOL_TCP, OPT_TBSIZE, &error, sizeof(error));
setsockopt(listensock, SOL_TCP, OPT_RBSIZE, &error, sizeof(error));
error = 1000;

setsockopt(listensock, SOL_TCP, OPT_TIMEWAIT_TIMEOUT, &error, sizeof(error));

blue_box_addr.sin_family = AF_INET;
blue_box_addr.sin_port = IPPORT_TELNET;
blue_box_addr.sin_addr.s_addr = INADDR_ANY;
tel = 0;
error = bind(listensock, &blue_box_addr, sizeof(blue_box_addr));

error = listen(listensock, 0);
while(TRUE)
{
sock = accept(listensock, NULL, NULL);
if(sock != RTCS_SOCKET_ERROR){
++telnet_count;
printf("\n\rConnection made %d\n\r",telnet_count);
send(sock,str,sizeof(str)-1,0);
_task_create(0,TELNET_CONNECTION,sock);
}
else printf("\r\nsocket error\r\n");

}
}

Labels (1)
Tags (1)
0 Kudos
1 Solution
325 Views
boogy
Contributor III

Every time you cycle through the loop you are executing the following : _task_create(0,TELNET_CONNECTION,sock);

You will eventually run out of memory.

View solution in original post

0 Kudos
1 Reply
326 Views
boogy
Contributor III

Every time you cycle through the loop you are executing the following : _task_create(0,TELNET_CONNECTION,sock);

You will eventually run out of memory.

0 Kudos