2
Hello,
I am facing a "SIGSEGV" error when receiving a large data packet with the recv function of the library using C language on a Posix - UNIX system, if any soul can help me a thank you.
buffer:
char ls_buffer_PPouAUT[2048] = {0};
rcv:
ln_retorno_receive = recv
(
in_socket_handler,
ls_buffer_PPouAUT,
sizeof(ls_buffer_PPouAUT),
0
);
ls_buffer_PPouAUT[ln_retorno_receive] = 0x00;
Socket:
int SocketConnect
(
char* as_host,
int an_port
)
{
int
ln_connection_status = 9;
//
// Variavel que guarda o retorno
//
GEDI_e_Ret ret;
//
// Cria o Socket
//
// AF_INET = ARPA INTERNET PROTOCOLS
// SOCK_STREAM = orientado a conexao
// 0 = protocolo padrao para o tipo escolhido -- TCP
in_socket_handler = socket (AF_INET, SOCK_STREAM, 0);
//
// Informa para conectar no server
//
// IP do servidor
server.sin_family = AF_INET;
// familia ARPANET
server.sin_addr.s_addr = inet_addr( as_host );
// Porta - hton = host to network short (2bytes) ou htons para mais
server.sin_port = htons ( an_port );
//
// Limpa varivavel
//
memset (
&(server.sin_zero),
0x00,
sizeof (server.sin_zero)
);
//
// Inicia comunicacao com server
//
if (
connect (
in_socket_handler,
(struct sockaddr *) &server,
sizeof (server)
)
< 0
)
{
//
// Se ocoreu uma falha
//
GEDI_LCD_DrawString(10, FONT_HEIGHT*10, FONT_WIDTH*1, FONT_HEIGHT*1,
" Falha ao criar socket! ");
GEDI_CLOCK_Delay(1000);
ln_connection_status = 9;
}
else
{
//
// Se conectou com sucesso
//
ln_connection_status = 0;
}
//
// Retorna o status da conexao.
//
return ln_connection_status;
}
Thank you. Lucas
Hello. Welcome to SOPT. If you haven’t done it yet, do the [tour] and read [Ask]. When you say "when receiving a big package", where exactly does the error occur? Have you debugged and retrieved the line of code where the error occurs? Have you checked the buffer (
ls_buffer_PPouAUT
- by the way, you did not put the code where it is allocated) managed to be allocated to the amount of bytes received? Without more details it’s hard to help you.– Luiz Vieira
Sorry, I’m new here
– Lucas Fernandes
I’ll edit it, thanks for the tip.
– Lucas Fernandes
Not at all. I withdrew my vote to close then. :)
– Luiz Vieira