Added a telnet_connect() function

This commit is contained in:
adamdunkels 2009-03-05 23:56:56 +00:00
parent 482de817e0
commit 6d545730ba
2 changed files with 42 additions and 29 deletions

View file

@ -28,7 +28,7 @@
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: telnet.c,v 1.1 2006/06/17 22:41:13 adamdunkels Exp $
* $Id: telnet.c,v 1.2 2009/03/05 23:56:56 adamdunkels Exp $
*
*/
@ -103,6 +103,18 @@ senddata(struct telnet_state *s)
uip_send(s->text, s->sentlen);
}
/*-----------------------------------------------------------------------------------*/
struct telnet_state *
telnet_connect(struct telnet_state *s, uip_ipaddr_t *addr, u16_t port)
{
struct uip_conn *conn;
conn = tcp_connect(addr, htons(port), s);
if(conn == NULL) {
return NULL;
}
return s;
}
/*-----------------------------------------------------------------------------------*/
void
telnet_app(void *ts)
{
@ -126,7 +138,6 @@ telnet_app(void *ts)
telnet_timedout(s);
}
if(s->flags & FLAG_CLOSE) {
uip_close();
return;

View file

@ -28,7 +28,7 @@
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: telnet.h,v 1.1 2006/06/17 22:41:13 adamdunkels Exp $
* $Id: telnet.h,v 1.2 2009/03/05 23:56:56 adamdunkels Exp $
*
*/
#ifndef __TELNET_H__
@ -48,6 +48,8 @@ void telnet_app(void *s);
unsigned char telnet_send(struct telnet_state *s, char *text, u16_t len);
unsigned char telnet_close(struct telnet_state *s);
unsigned char telnet_abort(struct telnet_state *s);
struct telnet_state *telnet_connect(struct telnet_state *s, uip_ipaddr_t *addr, u16_t port);
/* Callbacks, implemented by the caller. */
void telnet_connected(struct telnet_state *s);