Hi everyone.
I've questino to ask you guys.
I've written my own tcp functions. They work fine but my send function.
It work in Im_TCPVeriGonder(this echos the received ethernet packets).
But it does not work alone.
Here is my codework:
// close connection
static void Im_TCPBaglantiKapa(struct tcp_pcb *pcb)
{
tcp_arg(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_recv(pcb, NULL);
tcp_close(pcb);
}
// sent data
void Im_TCPVeriGonder(struct tcp_pcb *pcb,unsigned char * uc_gonderilecek_veri,unsigned int ui_veri_uzunlugu)
{
tcp_write(pcb, uc_gonderilecek_veri, ui_veri_uzunlugu, 0); /* Tampona atılan veri gönderiliyor.*/
tcp_sent(pcb, NULL); /* Paket sonunda boş karakter yollanıyor. */
pbuf_free(paket1);
}
// get received data
static err_t Im_TCPVeriAl(void *arg,struct tcp_pcb *pcb,struct pbuf *paket,err_t err)
{
if (err == ERR_OK && paket1 != NULL)
{
tcp_recved(pcb, paket1->tot_len);
g_p_uc_gelen_paket = (unsigned char *)paket1->payload;
g_ui_paket_uzunlugu = paket1->tot_len;
for(g_ui_index = 0; g_ui_index < g_ui_paket_uzunlugu; g_ui_index++)
{
g_uc_yigin_veri[g_ui_index] = g_p_uc_gelen_paket[g_ui_index];
}
// sent data
Im_TCPVeriGonder(pcb, "aliveli", 7);
}
else
{
pbuf_free(paket1); /* Paket tamponunu serbest bırakır. */
}
if (err == ERR_OK && paket1 == NULL)
{
Im_TCPBaglantiKapa(pcb);
}
return ERR_OK;
}
// Get the received data
static err_t Im_TCPTransferKontrol(void *arg, struct tcp_pcb *pcb, err_t err )
{
LWIP_UNUSED_ARG(arg);
LWIP_UNUSED_ARG(err);
tcp_setprio(pcb, TCP_PRIO_MIN);
tcp_recv(pcb, Im_TCPVeriAl);
tcp_err(pcb, NULL);
tcp_poll(pcb, NULL, 4);
return ERR_OK;
}
// Listening
void Im_BaglantiDinle()
{
if(baglanti_durumu == ERR_OK)
{
pcb = tcp_listen(pcb);
tcp_accept(pcb, Im_TCPTransferKontrol);
}
}
// Connect
void Im_BaglantiAc(void)
{
pcb = tcp_new();
baglanti_durumu = tcp_bind(pcb, IP_ADDR_ANY, PORT_NUMARASI);
}
My sent function works in Im_TCPVeriAl function(it gets the data sent from ethernet and echos it back) but can't work alone
Why can't I use my sent function?
Please give me suggestions.
My best regards...