mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 18:46:29 +00:00
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
This commit is contained in:
parent
6f6e411eef
commit
fa965094ed
2 changed files with 15 additions and 4 deletions
|
@ -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 = ../../..
|
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_GCCLIBS = stdc++
|
||||||
|
|
||||||
|
TARGET_LDFLAGS = -g
|
||||||
|
|
||||||
include $(PATH_TO_TOP)/rules.mak
|
include $(PATH_TO_TOP)/rules.mak
|
||||||
|
|
||||||
include $(TOOLS_PATH)/helper.mk
|
include $(TOOLS_PATH)/helper.mk
|
||||||
|
|
|
@ -178,10 +178,10 @@ void display_row( char *data, int off, int len ) {
|
||||||
int main( int argc, char **argv ) {
|
int main( int argc, char **argv ) {
|
||||||
int asock = INVALID_SOCKET, selret, dgrecv, fromsize, err, port = 5001;
|
int asock = INVALID_SOCKET, selret, dgrecv, fromsize, err, port = 5001;
|
||||||
char datagram[MAX_DG_SIZE];
|
char datagram[MAX_DG_SIZE];
|
||||||
void *conn;
|
void *conn = 0;
|
||||||
struct fd_set readf;
|
struct fd_set readf;
|
||||||
struct timeval tv;
|
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<std::string>::iterator i;
|
std::list<std::string>::iterator i;
|
||||||
WSADATA wsadata;
|
WSADATA wsadata;
|
||||||
|
|
||||||
|
@ -201,6 +201,9 @@ int main( int argc, char **argv ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addr_to.sin_port = htons( port & (~1) );
|
||||||
|
addr_to.sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||||
|
|
||||||
while( true ) {
|
while( true ) {
|
||||||
FD_ZERO( &readf );
|
FD_ZERO( &readf );
|
||||||
FD_SET( asock, &readf );
|
FD_SET( asock, &readf );
|
||||||
|
@ -241,7 +244,12 @@ int main( int argc, char **argv ) {
|
||||||
} else {
|
} else {
|
||||||
printf( "Socket created\n" );
|
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;
|
cmdin >> bytes;
|
||||||
|
|
||||||
if( (err = OskitTCPRecv( conn, (OSK_PCHAR)datagram,
|
if( (err = OskitTCPRecv( conn, (OSK_PCHAR)datagram,
|
||||||
|
@ -302,6 +310,7 @@ int main( int argc, char **argv ) {
|
||||||
}
|
}
|
||||||
} else if( word == "close" ) {
|
} else if( word == "close" ) {
|
||||||
OskitTCPClose( conn );
|
OskitTCPClose( conn );
|
||||||
|
conn = NULL;
|
||||||
}
|
}
|
||||||
} else if( dgrecv > 14 ) {
|
} else if( dgrecv > 14 ) {
|
||||||
addr_to = addr_from;
|
addr_to = addr_from;
|
||||||
|
|
Loading…
Reference in a new issue