diff -ubrpN -X exclude.patterns nmap.orig/nmap/nsock/src/nsock_connect.c nmap/nmap/nsock/src/nsock_connect.c
--- nmap.orig/nmap/nsock/src/nsock_connect.c	2010-05-13 19:46:24.269629827 +0000
+++ nmap/nmap/nsock/src/nsock_connect.c	2010-05-13 19:44:29.051344179 +0000
@@ -120,6 +120,13 @@ void nsock_connect_internal(mspool *ms, 
       }
     }
 
+    if (ms->broadcast) {
+      if (setsockopt(iod->sd, SOL_SOCKET, SO_BROADCAST, (void*)&(ms->broadcast), sizeof(int)) == -1) {
+        if (ms->tracelevel > 0)
+          nsock_trace(ms, "Setting of SO_BROADCAST failed (IOD #%li) EID %li", iod->id, nse->id);
+      }
+    }
+
     if (connect(iod->sd, (struct sockaddr *) ss, sslen) == -1) {
       int err = socket_errno();
 
diff -ubrpN -X exclude.patterns nmap.orig/nmap/nsock/src/nsock_internal.h nmap/nmap/nsock/src/nsock_internal.h
--- nmap.orig/nmap/nsock/src/nsock_internal.h	2010-05-13 19:46:24.265628759 +0000
+++ nmap/nmap/nsock/src/nsock_internal.h	2010-05-13 19:30:48.170451275 +0000
@@ -184,6 +184,7 @@ typedef struct  {
 		describe the error (errnum fashion) */
   int tracelevel; /* Trace/debug level - set by nsp_settrace.  If positive, trace logs are printted to
 		     stdout */
+  int broadcast; /* If true, new sockets will have SO_BROADCAST set */
   /* This time is subtracted from the current time for trace reports */
   struct timeval tracebasetime; 
 
diff -ubrpN -X exclude.patterns nmap.orig/nmap/nsock/src/nsock_pool.c nmap/nmap/nsock/src/nsock_pool.c
--- nmap.orig/nmap/nsock/src/nsock_pool.c	2010-05-13 19:46:24.253627790 +0000
+++ nmap/nmap/nsock/src/nsock_pool.c	2010-05-13 19:41:08.478646381 +0000
@@ -137,6 +137,15 @@ void nsp_settrace(nsock_pool nsp, int le
   else mt->tracebasetime = *basetime;
 }
 
+/* Turns on or off broadcast support on new sockets. Default is off 
+   (0, false) set in nsp_new(). Any non-zero (true) value sets 
+   SO_BROADCAST on all new sockets (value of optval will be used directly
+   in the setsockopt() call */
+void nsp_setbroadcast(nsock_pool nsp, int optval) {
+  mspool *mt = (mspool *) nsp;
+  mt->broadcast = optval;
+}
+
 /* And here is how you create an nsock_pool.  This allocates, initializes,
    and returns an nsock_pool event aggregator.  In the case of error,
    NULL will be returned.  If you do not wish to immediately associate
@@ -149,6 +158,7 @@ nsock_pool nsp_new(void *userdata) {
   gettimeofday(&nsock_tod, NULL);
 
   nsp->tracelevel = 0;
+  nsp->broadcast = 0;
   if (!nsocklib_initialized) {
     nsock_library_initialize();
     nsocklib_initialized = 1;
diff -ubrpN -X exclude.patterns nmap.orig/nmap/ncat/ncat_connect.c nmap/nmap/ncat/ncat_connect.c
--- nmap.orig/nmap/ncat/ncat_connect.c	2010-05-13 19:46:32.945630472 +0000
+++ nmap/nmap/ncat/ncat_connect.c	2010-05-13 19:57:51.405647409 +0000
@@ -468,6 +468,9 @@ int ncat_connect(void) {
         /* A trace level of 1 still gives you an awful lot. */
         nsp_settrace(mypool, 1, nsock_gettimeofday());
 
+    if (o.broadcast)
+        nsp_setbroadcast(mypool, 1);	
+
 #ifdef HAVE_OPENSSL
     set_ssl_ctx_options((SSL_CTX *)nsp_ssl_init(mypool));
 #endif
diff -ubrpN -X exclude.patterns nmap.orig/nmap/ncat/ncat_core.c nmap/nmap/ncat/ncat_core.c
--- nmap.orig/nmap/ncat/ncat_core.c	2010-05-13 19:46:32.977628125 +0000
+++ nmap/nmap/ncat/ncat_core.c	2010-05-13 20:02:11.333645780 +0000
@@ -131,6 +131,7 @@ void options_init(void) {
     o.listen = 0;
     o.keepopen = 0;
     o.sendonly = 0;
+    o.broadcast = 0;
     o.recvonly = 0;
     o.telnet = 0;
     o.udp = 0;
diff -ubrpN -X exclude.patterns nmap.orig/nmap/ncat/ncat_core.h nmap/nmap/ncat/ncat_core.h
--- nmap.orig/nmap/ncat/ncat_core.h	2010-05-13 19:46:32.949639922 +0000
+++ nmap/nmap/ncat/ncat_core.h	2010-05-13 20:01:39.502745549 +0000
@@ -113,6 +113,7 @@ struct options {
     int keepopen;
     int sendonly;
     int recvonly;
+    int broadcast;
     int telnet;
     int udp;
     int sctp;
diff -ubrpN -X exclude.patterns nmap.orig/nmap/ncat/ncat_main.c nmap/nmap/ncat/ncat_main.c
--- nmap.orig/nmap/ncat/ncat_main.c	2010-05-13 19:46:32.969627944 +0000
+++ nmap/nmap/ncat/ncat_main.c	2010-05-13 20:00:54.401629586 +0000
@@ -245,6 +245,7 @@ int main(int argc, char *argv[])
         {"source-port",     required_argument,  NULL,         'p'},
         {"source",          required_argument,  NULL,         's'},
         {"send-only",       no_argument,        &o.sendonly,  1},
+        {"broadcast",       no_argument,        &o.broadcast, 1},
         {"broker",          no_argument,        NULL,         0},
         {"chat",            no_argument,        NULL,         0},
         {"talk",            no_argument,        NULL,         0},
