From fa965094ed4e5230b020122182d25bbcd4c94386 Mon Sep 17 00:00:00 2001 From: Art Yerkes Date: Tue, 21 Sep 2004 04:06:15 +0000 Subject: [PATCH] Fixed tcptest to not do send recv or close on a socket that's not connected. This keeps the user from doing something inappropriate. makefile: add -g back in svn path=/trunk/; revision=10952 --- reactos/apps/tests/oskittcp/makefile | 4 +++- reactos/apps/tests/oskittcp/tcptest.cpp | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/reactos/apps/tests/oskittcp/makefile b/reactos/apps/tests/oskittcp/makefile index 2778929ac7f..9bbf9a386a6 100644 --- a/reactos/apps/tests/oskittcp/makefile +++ b/reactos/apps/tests/oskittcp/makefile @@ -1,5 +1,5 @@ # -# $Id: makefile,v 1.4 2004/09/13 03:14:35 royce Exp $ +# $Id: makefile,v 1.5 2004/09/21 04:06:15 arty Exp $ PATH_TO_TOP = ../../.. @@ -19,6 +19,8 @@ TARGET_CPPFLAGS = -I$(PATH_TO_TOP)/drivers/lib/oskittcp/include -I$(PATH_TO_TOP TARGET_GCCLIBS = stdc++ +TARGET_LDFLAGS = -g + include $(PATH_TO_TOP)/rules.mak include $(TOOLS_PATH)/helper.mk diff --git a/reactos/apps/tests/oskittcp/tcptest.cpp b/reactos/apps/tests/oskittcp/tcptest.cpp index 46ab5f39ebd..b86a73d5f9c 100644 --- a/reactos/apps/tests/oskittcp/tcptest.cpp +++ b/reactos/apps/tests/oskittcp/tcptest.cpp @@ -178,10 +178,10 @@ void display_row( char *data, int off, int len ) { int main( int argc, char **argv ) { int asock = INVALID_SOCKET, selret, dgrecv, fromsize, err, port = 5001; char datagram[MAX_DG_SIZE]; - void *conn; + void *conn = 0; struct fd_set readf; struct timeval tv; - struct sockaddr_in addr_from = { AF_INET }, addr_to; + struct sockaddr_in addr_from = { AF_INET }, addr_to = { AF_INET }; std::list::iterator i; WSADATA wsadata; @@ -201,6 +201,9 @@ int main( int argc, char **argv ) { return 0; } + addr_to.sin_port = htons( port & (~1) ); + addr_to.sin_addr.s_addr = inet_addr("127.0.0.1"); + while( true ) { FD_ZERO( &readf ); FD_SET( asock, &readf ); @@ -241,7 +244,12 @@ int main( int argc, char **argv ) { } else { printf( "Socket created\n" ); } - } else if( word == "recv" ) { + } + + /* The rest of the commands apply only to an open socket */ + if( !conn ) continue; + + if( word == "recv" ) { cmdin >> bytes; if( (err = OskitTCPRecv( conn, (OSK_PCHAR)datagram, @@ -302,6 +310,7 @@ int main( int argc, char **argv ) { } } else if( word == "close" ) { OskitTCPClose( conn ); + conn = NULL; } } else if( dgrecv > 14 ) { addr_to = addr_from;