[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] [lwip] API question
From: |
DASILVA VINCENTE BIT |
Subject: |
[lwip-users] [lwip] API question |
Date: |
Wed, 08 Jan 2003 22:21:51 -0000 |
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_000_01C1BA0C.2EFC5FF0
Content-Type: text/plain;
charset="iso-8859-1"
If I start 2 processes using the function loopif() am I correct to assume
that the tcpecho_thread will create a connection on port 7 address 127.0.0.1
and start listening.
tcpwrite_thread is then called and creates a connection on port 8 address
127.0.0.1 and then sends the text "Test" to port 7 address 127.0.0.1. At
this point tcpecho_thread will continue and should receive the data "Test".
I think maybe I have a problem with the way I am using the API.
Thanks in advance
Vicente
static void loopif()KCREENTRANT
{
struct ip_addr ipaddr, netmask, gw;
OS_EVENT* sem;
IP4_ADDR(&gw, 127,0,0,1);
IP4_ADDR(&ipaddr, 127,0,0,1);
IP4_ADDR(&netmask, 255,0,0,0);
netif_set_default(netif_add(&ipaddr, &netmask, &gw,
loopif_init,tcpip_input));
sem = sys_sem_new(0);
tcpip_init(tcpip_init_done, sem);
sys_sem_wait(sem);
sys_sem_free(sem);
sem = sys_sem_new(0);
tcpecho_init(sem);
sys_sem_wait(sem);
sys_sem_free(sem);
tcpwrite_init();
sem = sys_sem_new(0);
sys_sem_wait(sem);
}
static void
tcpwrite_thread(void *arg)KCREENTRANT
{
struct netconn *conn;
struct ip_addr ipaddr;
char text[] = "Test";
OS_EVENT* sem;
IP4_ADDR(&ipaddr, 127,0,0,1);
conn = netconn_new(NETCONN_TCP);
netconn_bind(conn, &ipaddr, 8);
netconn_connect(conn,&ipaddr, 7);
netconn_write(conn, text, sizeof(text), NETCONN_NOCOPY);
netconn_close(conn);
sem = sys_sem_new(0);
sys_sem_wait(sem);
}
static void
tcpecho_thread(void *arg)KCREENTRANT
{
struct netconn *conn, *newconn;
err_t err;
struct ip_addr ipaddr;
OS_EVENT* sem;
IP4_ADDR(&ipaddr, 127,0,0,1);
conn = netconn_new(NETCONN_TCP);
netconn_bind(conn, &ipaddr, 7);
sys_sem_signal((OS_EVENT *)echo_ready_arg);
netconn_listen(conn);
while(1)
{
// Grab new connection.
newconn = netconn_accept(conn);
if(newconn != NULL)
{
struct netbuf *buf;
void *data;
u16_t len;
while((buf = netconn_recv(newconn)) != NULL)
{
do
{
netbuf_data(buf, &data, &len);
//err = netconn_write(newconn, data, len, NETCONN_COPY);
//if(err != ERR_OK)
//{
/* printf("tcpecho: netconn_write: error \"%s\"\n",
lwip_strerr(err));*/
//}
} while(netbuf_next(buf) >= 0);
netbuf_delete(buf);
}
netconn_delete(newconn);
}
}
}
------_=_NextPart_000_01C1BA0C.2EFC5FF0
Content-Type: application/octet-stream;
name="Vicente Da Silva.vcf"
Content-Disposition: attachment;
filename="Vicente Da Silva.vcf"
BEGIN:VCARD
VERSION:2.1
N:Da Silva;Vicente
FN:Vicente Da Silva
ORG:BATELEUR Resourcing (Pty) Ltd
TITLE:Consultant
TEL;CELL;VOICE:+27 (082) 377-0118
EMAIL;PREF;INTERNET:address@hidden
REV:20020215T084009Z
END:VCARD
------_=_NextPart_000_01C1BA0C.2EFC5FF0--
[This message was sent through the lwip discussion list.]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-users] [lwip] API question,
DASILVA VINCENTE BIT <=