lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Re: [lwip] client- TCP/IP Slip Connection


From: Adam Dunkels
Subject: [lwip-users] Re: [lwip] client- TCP/IP Slip Connection
Date: Wed, 08 Jan 2003 22:37:46 -0000

Hi!

On Friday 23 November 2001 11.49, you wrote:
> We have the board connected to a PC through a SLIP connection. We want
> to have the client in the Micro and the server in the PC. The server is
> working and listening but when we send the info from the client
> (microcontroller) the server does not recieve anything.
>
> This is the code in the microcontroller that sends the info to the
> server....
>
>   struct tcp_pcb *pcb;
>   struct ip_addr ipaddr;
>   char buf[100];
>
>   IP4_ADDR(&ipaddr,192,168,0,1);
>
>   pcb = tcp_pcb_new();
>
>    sprintf(buf, "%s\n",str);
>
>   tcp_connect(pcb,&ipaddr,SERVER_TO_SEND_ANSWERS_PORT,http_void, NULL);
>
>   tcp_write(pcb,(void *)buf,sizeof(buf)-1,0);
>
>   if(tcp_close(pcb) != ERR_OK)
>     tcp_abort(pcb);
>
> We have tested the server without a SLIP connection and it works.
>
> We would be very pleased if you can give us any suggestions !!

The problem is that the connection isn't connected when tcp_write() is 
called. The return value of tcp_write() should be ERR_CONN to indicate this.

The way to go about this is to do the tcp_write() in the callback function 
that will be called when the connection is connected. (In the same fashion as 
when doing the tcp_write() from the accept callback function.) That would be 
from the http_void() function in your case.

A couple of suggestions: download the latest CVS code, and try it instead. 
Note that tcp_pcb_new() has been renamed to tcp_new() in the new code and 
that the callback argument is set by a call to the new tcp_arg() function. 
Look in the proj/unixsim/apps/http_noapi.c for an example of how to use the 
new functions. 

I will write a small document on how the raw stack API works when I get the 
time for it...

/adam
-- 
Adam Dunkels <address@hidden>
http://www.sics.se/~adam
[This message was sent through the lwip discussion list.]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]