[ds6-devel] nc6/src main.c,1.8,1.9 network.c,1.18,1.19

chris@deepspace6.net chris@deepspace6.net
Sat Dec 28 19:01:43 2002


Update of /cvs/nc6/src

Modified Files:
	main.c network.c 
Log Message:
Moved creation of local io_stream out of network code to main.
Moved verbose logging of connection type out of network code to main.


Index: main.c
===================================================================
RCS file: /cvs/nc6/src/main.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- main.c	24 Dec 2002 21:05:37 -0000	1.8
+++ main.c	28 Dec 2002 19:01:41 -0000	1.9
@@ -56,7 +56,10 @@
 	/* set flags and fill out the addresses and connection attributes */
 	mode = parse_arguments(argc, argv, &connection_attrs);
 
-	/* establish a connection */
+	/* setup local stream */
+	ios_assign_stdio(&(connection_attrs.local_stream));
+
+	/* establish remote connection */
 	switch (mode) {
 	case LISTEN_MODE:
 		do_listen(&connection_attrs);
@@ -66,9 +69,24 @@
 		break;
 	default:
 		fatal("internal error: unknown connection mode");
-		break;
 	}
 
+	/* give information about the connection in very verbose mode */
+	if (is_flag_set(VERY_VERBOSE_MODE) == TRUE) {
+		switch (connection_attrs.remote_stream.socktype) {
+		case SOCK_STREAM:
+			warn("using stream socket");
+			break;
+		case SOCK_DGRAM:
+			warn("using datagram socket");
+			break;
+		default:
+			fatal("internal error: unsupported socktype %d",
+			      connection_attrs.remote_stream.socktype);
+		}
+	}
+
+
 	/* setup unidirectional data transfers (if requested) */
 	assert(!(is_flag_set(RECV_DATA_ONLY) && is_flag_set(SEND_DATA_ONLY)));
 
@@ -77,10 +95,8 @@
 
 		/* close the remote stream for writing */
 		ios_shutdown(&(connection_attrs.remote_stream), SHUT_WR);
-
 		/* close the local stream for reading */
 		ios_shutdown(&(connection_attrs.local_stream), SHUT_RD);
-
 		/* don't stop because the read is closed */
 		ios_set_hold_timeout(&(connection_attrs.local_stream), -1);
 
@@ -95,10 +111,8 @@
 
 		/* close the remote stream for reading */
 		ios_shutdown(&(connection_attrs.remote_stream), SHUT_RD);
-
 		/* don't stop because the read is closed */
 		ios_set_hold_timeout(&(connection_attrs.remote_stream), -1);
-
 		/* close the local stream for writing */
 		ios_shutdown(&(connection_attrs.local_stream), SHUT_WR);
 
Index: network.c
===================================================================
RCS file: /cvs/nc6/src/network.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- network.c	28 Dec 2002 09:55:45 -0000	1.18
+++ network.c	28 Dec 2002 19:01:41 -0000	1.19
@@ -301,13 +301,7 @@
 		     sbuf_num, sbuf_rev);
 	}
 
-	if (is_flag_set(VERY_VERBOSE_MODE) == TRUE) {
-		warn("using %s socket",
-		     (ptr->ai_socktype == SOCK_STREAM)? "stream":"datagram");
-	}
-
-	/* fill out the io_streams for the local and remote */
-	ios_assign_stdio(&(attrs->local_stream));
+	/* fill out the remote io_stream */
 	ios_assign_socket(&(attrs->remote_stream), fd, ptr->ai_socktype);
 
 	/* cleanup addrinfo structure */
@@ -637,12 +631,6 @@
 				     c_hbuf_rev, c_hbuf_num, c_sbuf_num);
 			}
 
-			if (is_flag_set(VERY_VERBOSE_MODE) == TRUE) {
-				warn("using %s socket",
-				     (socktype == SOCK_STREAM)?
-				         "stream":"datagram");
-			}
-
 			break;
 		} else {
 			if (socktype == SOCK_DGRAM) {
@@ -673,7 +661,6 @@
 	/* free the fd_socktype list */
 	destroy_fd_socktypes(fd_socktypes);
 
-	/* create io_streams for the local and remote streams */
-	ios_assign_stdio(&(attrs->local_stream));
+	/* fill out the remote io_stream */
 	ios_assign_socket(&(attrs->remote_stream), ns, socktype);
 }



More information about the ds6-devel mailing list