The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / dumpcap.c @ master

History | View | Annotate | Download (190 KB)

# Date Author Comment
97546165 08/24/2014 04:04 AM Graham Bloice

Modify includes of config.h so that out-of-tree builds, i.e. CMake
don't pick up the in-tree copy.

Change-Id: I7ec473876cdba1a025c52362d7f6adc62d24ce71
Reviewed-on: https://code.wireshark.org/review/3798
Petri-Dish: Graham Bloice <>...

bed29af4 08/20/2014 11:34 PM Roland Knall

Extcap Capture Interface

Extcap is a plugin interface, which allows for the usage
of external capture interfaces via pipes using a predefined
configuration language which results in a graphical gui.
This implementation seeks for a generic implementation,...
657d5f9c 08/05/2014 05:53 PM Joerg Mayer

- Fix the whitespace fix
- Also, trying to commit this "properly" gave this message:
Error: Found prohibited APIs in dumpcap.c: strncpy,htons,strerror,open
How does this happen? Why does gerrit accept this stuff in case a
user does not have the (current) hooks installed?...

f3dd7fe1 08/05/2014 04:42 PM Bill Meier

Fix whitespace/indentation to match editor modelines.

Change-Id: I3445ae22f10584582d465bf632942e016f5f70ca
Reviewed-on: https://code.wireshark.org/review/3452
Reviewed-by: Bill Meier <>

4028f567 07/22/2014 07:57 PM Guy Harris

Clean up indentation (get rid of tabs).

Change-Id: I14917737db30c80af2d40e40efd79ceb6aea79f8
Reviewed-on: https://code.wireshark.org/review/3170
Reviewed-by: Guy Harris <>

f6ce0cda 07/22/2014 07:53 PM Guy Harris

Get rid of NO_INTERFACES_FOUND - it's not an error.

It just means "pcap didn't give me any interfaces, and didn't report an
error". Hopefully, in the future, there will be pcap APIs that
distinguish between the (admittedly unlikely, these days) case of "there...

9e6487f2 07/04/2014 03:25 AM Guy Harris

Move utility routines for capturing into a libcaputils static library.

Some of those routines are used only in dumpcap; others are used in
TShark and Wireshark as well.

Change-Id: I9d92483f2fcff57a7d8b6bf6bdf2870505d19fb7
Reviewed-on: https://code.wireshark.org/review/2841...

a1ec6693 07/03/2014 04:58 AM Guy Harris

Clean up printf() argument list.

Splitting %s from \n makes it clearer that the %s's in question take
arguments that already include a newline, and that the subsequent \n
adds a blank line.

Change-Id: I5bac8ca80b42f7de980ad29480042cae3166ff7e
Reviewed-on: https://code.wireshark.org/review/2797...

b4ce3525 07/03/2014 04:46 AM Guy Harris

Make --help and --version information a bit more uniform.

Have --version print the version number, the copyright information, the
"compiled with" information, the "running on/with" information, and the
compiler information.

Have --help print the version number, a one-line summary of what the...

6b3391c6 07/02/2014 10:29 PM Guy Harris

Regularize the help output of programs.

Only print to the standard output, and only give the version
information, if a "print help" command-line option is specified.
Otherwise, leave out the version information, and print to the standard
error.

Leave out the copyright information; it's extra cruft, and...

66c342ed 07/02/2014 10:03 PM Guy Harris

Regularize the first line of version output.

For Wireshark, say "Wireshark", not "wireshark".

For other programs, put "(Wireshark)" after the program name, as per

http://www.gnu.org/prep/standards/html_node/_002d_002dversion.html

("If the program is a subsidiary part of a larger package, mention the...

b33512b7 06/30/2014 01:09 AM Guy Harris

Move capture_session.h to capchild; what it declares is defined there.

Change-Id: I8b1407839390b7ac0b45bf6f583c1a509073f002
Reviewed-on: https://code.wireshark.org/review/2709
Reviewed-by: Guy Harris <>

fe42762f 06/29/2014 07:03 PM Guy Harris

Move some more stuff into wsutil.

Move the routines to parse numerical command-line arguments there.

Make cmdarg_err() and cmdarg_err_cont() routines in wsutil that just
call routines specified by a call to cmdarg_err_init(), and have
programs supply the appropriate routines to it....

adf6b1a8 06/23/2014 08:28 PM Guy Harris

For capchild headers, include <capchild/XXX.h>.

Change-Id: I780c69ee637dcd9846756a2e2d6a35baf02d826d
Reviewed-on: https://code.wireshark.org/review/2594
Reviewed-by: Guy Harris <>

1d92195d 06/23/2014 05:56 PM Guy Harris

Have individual programs get libpcap and libz version info.

That way, the code that constructs the runtime version string doesn't
itself have to call libpcap and libz, and could be usable in programs
that don't call them.

While we're at it, add "with" to the run-time version information for...

c46329c2 06/21/2014 09:06 PM Guy Harris

Add a routine to return a version string including VCS information.

Add a routine get_ws_vcs_version_info() that, for builds from a tree
checked out from Wireshark's version control system, returns a string
that includes both the Wireshark version number and an indication of...

a1112249 06/21/2014 02:02 PM Guy Harris

Move get_os_version_info() to libwsutil.

This mean we also have to move CFString_to_C_string() there for OS X.

Change-Id: Ic91ad872e9d5290cf34f842503ededd5452e4337
Reviewed-on: https://code.wireshark.org/review/2511
Reviewed-by: Guy Harris <>

43443af0 06/21/2014 01:33 PM Guy Harris

Move get_copyright_info() to wsutil.

Change-Id: I75c1c747cd2b4a9845c659636582d54b2caecf1a
Reviewed-on: https://code.wireshark.org/review/2510
Reviewed-by: Guy Harris <>

b2622e11 06/20/2014 07:43 PM Guy Harris

Move the "capture-comment" long option to LONGOPT_CAPTURE_COMMON.

Change-Id: I55884d48911de307cde52accfebbda69f2989526
Reviewed-on: https://code.wireshark.org/review/2505
Reviewed-by: Guy Harris <>

b3885a93 06/20/2014 05:51 PM Guy Harris

Fix builds without pcap.

Change-Id: I6c67f9ea9d115a8396af0904ef9a73d2c528dcaa
Reviewed-on: https://code.wireshark.org/review/2498
Reviewed-by: Guy Harris <>

5537c53f 06/20/2014 05:32 PM Guy Harris

"-d" isn't common to all capturing programs, it's dumpcap-specific.

Change-Id: I827615d45051c9d66407516b311d3de448de6d07
Reviewed-on: https://code.wireshark.org/review/2495
Reviewed-by: Guy Harris <>

26bbee3f 06/20/2014 05:00 PM Guy Harris

Add some long options for capture short options.

The names match tcpdump trunk's names for the corresponding options.

Also have capture_opts.h provide a #define for the part of the short
option string that corresponds to the capture short options that all our...

312ed109 06/20/2014 03:19 PM Guy Harris

Add --help and --version long options.

Also, make the convention for long-only options be that their
case-statement values start at 128, so they avoid colliding with any
ASCII code points, including control characters.

Make the tables of long options "static const" while we're at it, and...

aa3a968e 05/08/2014 03:58 PM AndersBroman

Profiling show that g_log() takes a lot of CPU even when logging isn't
active.

Change-Id: I242f8e98a77861c0174e432c7026964babae7299
Reviewed-on: https://code.wireshark.org/review/1565
Reviewed-by: Anders Broman <>

29659139 03/04/2014 09:27 AM Alexis La Goutte

Remove all $Id$ from top of file

(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <>

c875dc85 02/27/2014 12:57 PM Hadriel Kaplan

Fix dumpcap.c: Assigned value is garbage or undefined (clang analyzer)

Change-Id: I61dbf5e1e206b1c0d2e594bfba38e83e51e8f09c
Reviewed-on: https://code.wireshark.org/review/371
Reviewed-by: Evan Huus <>
Tested-by: Evan Huus <>

f9669809 02/07/2014 06:03 PM Gerald Combs

Replace "svn" with "git" all over the place.

Rename "SVNPATH" to "GITBRANCH" since that seems more appropriate.
Rename "svnversion.h" to "version.h" as Evan suggested. Update some
URLs. In make-version.pl, make sure we don't set an improper upstream
branch name. Use the number of commits + short hash from `git describe`...

c852f994 01/17/2014 03:06 PM Martin Kaiser

From Toralf Förster
fix format strings for signed integers

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9637

svn path=/trunk/; revision=54835

90ea2352 01/17/2014 02:35 PM Anders Broman

Fix [-Wmissing-prototypes]

svn path=/trunk/; revision=54834

064082e6 12/20/2013 05:39 PM Jakub Zawadzki

Change G_GINT64_CONSTANT(xxxxU) to G_GUINT64_CONSTANT(xxxx)

svn path=/trunk/; revision=54314

87e2aa33 12/17/2013 10:02 AM Bill Meier

From "bd": Fix " Wireshark stops showing new packets but dumpcap keeps writing them to the temp file"

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9571

From me: Fixed in a slightly different manner than sugested in the patch attached to the bug.
...

93f15d64 12/02/2013 02:17 PM Chris Maynard

Specify SI units for the max filesize autostop condition. For now, keep the capture buffer size in IEC units, but document it as such.
#BACKPORT)

svn path=/trunk/; revision=53728

d99fdfda 11/29/2013 02:21 PM Jakub Zawadzki

Replace macros: BSWAP16, BSWAP32, BSWAP64 with glib-version.

XXX, people are not aware that expression of this macros might be evaluated multiple times, like:
- BSWAP16) : \
+ GUINT16_SWAP_LE_BE(tvb_get_letohs(tvb, off)) : \...

b5e69855 11/25/2013 10:13 PM Guy Harris

Report the interface when an open or an attempt to set the link-layer
header type fails, as we might be capturing on more than one interface.

Report the failing interface name in single quotes in some places where
we weren't doing so, for stylistic consistency....

c9b2ee37 11/09/2013 10:44 AM Jakub Zawadzki

include <wsutil/pint.h> only when needed.

svn path=/trunk/; revision=53196

996b07a8 11/04/2013 02:38 PM Anders Broman

Print if_dropped

svn path=/trunk/; revision=53080

b0687639 09/29/2013 04:53 PM Guy Harris

Rename routines that write pcap-ng files to "pcapng_xxx" rather than
"libpcap_xxx".

Rename the low-level write routine in pcapio.c to write_to_file(), as
it's used for both pcap and pcap-ng files.

svn path=/trunk/; revision=52275

c42263f2 09/29/2013 04:26 PM Guy Harris

We always write to a FILE *, so:

make libpcap_write_to_file() static;
don't pass it as an argument to write routines, just have them
call it directly;
make the handle argument a FILE *.

Make the data length argument to libpcap_write_to_file() a size_t, as...

bc654875 08/29/2013 02:15 PM Chris Maynard

Handle the 2GiB boundary case of the max filesize autostop condition properly so that we avoid overflow conditions and so that we ensure we don't capture more than 2GiB. Also, document the max filesize autostop value of 2GIB as well as indicating that it's truly GiB and not GB....

a75499aa 08/25/2013 06:41 PM Gerald Combs

Check our recently-added signal pipe in statistics mode.

svn path=/trunk/; revision=51519

71f7093c 08/23/2013 01:25 AM Anders Broman

Output a warning about kernel BPF JIT compiler beeing activated.

svn path=/trunk/; revision=51488

f9aaaebd 08/23/2013 01:21 AM Anders Broman

Output a warning about kernel BPF JIT compiler beeing activated.

svn path=/trunk/; revision=51487

9e7ce8b8 08/22/2013 02:49 PM Martin Kaiser

fix compiler warning on Debian wheezy (gcc 4.7.2)

dumpcap.c:193:10: error: ignoring return value of ‘write’, declared with
attribute warn_unused_result [-Werror=unused-result]

for some reason, using (void)write(fd, ...) did not do the trick

svn path=/trunk/; revision=51476

347ea71b 08/22/2013 01:36 PM Guy Harris

Only enable the Linux kernel BPF JIT compiler if we're on Linux.

Unless we're going to do something if that fails, there's no point in
having enable_kernel_bpf_jit_compiler() return a success/failure
indication.

Fix indentation.

svn path=/trunk/; revision=51475

5928ded2 08/22/2013 01:20 PM Anders Broman

Enable Kernel BPF JIT compiler from dumpcap.

svn path=/trunk/; revision=51472

da7c9208 08/13/2013 09:21 PM Guy Harris

I guess Solaris's getopt_long() "struct option" declaration doesn't have
enough cowbell^wconst; throw in a comment to squelch warnings.

svn path=/trunk/; revision=51351

a1abe154 08/10/2013 05:27 PM Alexis La Goutte

Fix error when build with clang 3.0

dumpcap.c:3981:88: error: implicit conversion loses integer precision: 'const __suseconds_t'
(aka 'const long') to 'guint32' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
phdr->ts.tv_sec, phdr->ts.tv_usec,...

1a0b16d1 07/29/2013 11:45 AM Chris Maynard

Trivial: Wrap text at column 80.

svn path=/trunk/; revision=51012

9e33a6ba 07/27/2013 12:48 PM Martin Kaiser

if we capture on multiple interfaces, the output file will be pcapn-ng
even if we enforce pcap ouput format via -P

in such a case, we can write a capture comment to the output file

svn path=/trunk/; revision=50948

82ea635a 07/27/2013 12:25 PM Martin Kaiser

command line option --capture-comment for dumpcap

svn path=/trunk/; revision=50945

a585b453 07/27/2013 12:16 PM Martin Kaiser

use capture_comment from the capture_options structure
when we write the SHB

svn path=/trunk/; revision=50944

14c82477 07/24/2013 04:42 PM Martin Kaiser

use getopt_long() in dumpcap

for now, there's no long options, this is just a first test to see if
things compile everywhere...

svn path=/trunk/; revision=50877

91ecc233 07/16/2013 12:23 PM Chris Maynard

"man inet_pton" only says that it returns a negative value, zero or a postive value, and not specifically -1, 0, or 1, so even though we know that's what wsutil's inet_pton will return, we shouldn't test against those exact values.

svn path=/trunk/; revision=50670

42b09314 07/15/2013 11:51 AM Chris Maynard

C++ style comments are not allowed in ISO C90. (Fixes the rest of them now that I noticed, "this will be reported only once per input file")

svn path=/trunk/; revision=50613

e7e260b4 07/15/2013 11:48 AM Chris Maynard

Trivial: C++ style comments are not allowed in ISO C90.

svn path=/trunk/; revision=50612

0bdc0efc 06/27/2013 01:10 PM Luis Ontanon

get main_window_update out of the way... pass an update_cb to the capture_sync stuff
... as per the XXX comment removed from tshark.c this was a mess to keep the linker
happy... I couldn't!

I did this without even understanding whether calling main_window_update was realy...

bbf6a376 06/25/2013 09:14 PM Jeff Morriss

Move tempfile.{h,c} into wsutil.

svn path=/trunk/; revision=50163

78e334b8 06/04/2013 12:36 AM Anders Broman

From Mike Garratt:
Friendly Names support causing unnecessary delay when Wireshark starts.

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8034

svn path=/trunk/; revision=49752

8596d17d 05/22/2013 03:44 AM Guy Harris

Pull the capture-session state information out of capture_opts and put
it into a separate capture_session structure. capture_opts should
contain only user-specified option information (and stuff directly
derived from it, such as the "capturing from a pipe" flag)....

1ca63098 05/22/2013 12:49 AM Guy Harris

Rename capture_opts_trim_iface() to
capture_opts_default_iface_if_necessary(), to reflect what it actually
does.

svn path=/trunk/; revision=49491

c1d34d4b 05/21/2013 09:19 PM Guy Harris

On OS X, get the interface type from the System Configuration framework.

svn path=/trunk/; revision=49486

39779a7b 04/25/2013 01:47 AM Guy Harris

Send the output of the -D and -L options to the standard output rather
than the standard error.

In Wireshark on Windows, create a console before doing so and destroy it
before exiting. Don't do that in TShark or dumpcap, as those are
console-mode programs on Windows....

26ddabf0 03/19/2013 01:09 AM Anders Broman

From Michal Labedzki:

Fix some compilation errors in dumpcap/plugins

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8304

svn path=/trunk/; revision=48413

da07699d 03/10/2013 07:57 AM Michael Tüxen

Make the memory limit (in bytes or packets) used for storing packets
configurable via command line options and print specific drop numbers
at the end. This allows to tune the buffering when using multiple
threads.
This also fixes a logic arrow in enforcing the limits....

85973068 03/03/2013 12:14 PM Anders Broman

From beroset:
remove C++ incompatibilities

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416

svn path=/trunk/; revision=48038

d0992bf8 02/28/2013 10:27 AM Jeff Morriss

Add a #define for the default capture buffer size and use it.

svn path=/trunk/; revision=47942

1a4fb17e 02/28/2013 01:37 AM Anders Broman

Update the text of dumpcap -h, default buffer size should be 2 MB.

svn path=/trunk/; revision=47935

4d9850f6 02/25/2013 08:43 PM Bill Meier

it's ==> its

svn path=/trunk/; revision=47894

bd4cffae 02/19/2013 08:19 PM Gerald Combs

When any of our executables start on Windows create or open a "Wireshark
is running" mutex. Have the NSIS installer check for this mutex and ask
the user to close Wireshark if it's found. While not perfect this makes
the WinSparkle update process much less annoying....

e90f414a 01/22/2013 03:28 AM Anders Broman

svn path=/trunk/; revision=47210

05825b02 01/15/2013 04:54 PM Guy Harris

Add some routines to wsutil to, at least on some platforms, add
information to crash dumps and the like. (Currently, we only handle OS
X's CrashReporter, but we should do this on other platforms where this
information can be added and would be helpful.)
...

18580d67 01/01/2013 11:01 PM Michael Mann

Allow pcap/pcapng format to be written to more than just a file (FILE*). Gives more flexibility if needed.

WRITE_DATA macro replaced and applied consistently throughout pcapio.c

svn path=/trunk/; revision=46891

8106e331 12/26/2012 10:02 AM Anders Broman

Make dumpcap build on Windows

svn path=/trunk/; revision=46788

8ed7a73e 12/26/2012 12:57 AM Guy Harris

Fix a bunch of warnings.

Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
sizeof.

Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
strtol() and strtoul().

Change some data types to avoid those implicit conversion warnings....

e0ed1bdd 12/23/2012 04:54 AM Guy Harris

More whitespace cleanups.

svn path=/trunk/; revision=46716

644f8485 12/23/2012 04:25 AM Michael Tüxen

Add support for writing per packet comments when using pcapng.
Not actually used with this commit, which just brings in the
infrastructure.

svn path=/trunk/; revision=46715

bb846842 12/23/2012 01:52 AM Guy Harris

Fix indentation.

svn path=/trunk/; revision=46712

0ddce652 12/20/2012 03:00 PM Guy Harris

fclose() and fflush() are standard C routines, so there's no need for
our own wrappers. (pcapio.c isn't using wrappers around, for example,
fwrite().)

svn path=/trunk/; revision=46640

9a2f4c8e 12/20/2012 10:20 AM Michael Tüxen

Don't use an pcap structures in pcapio.[ch].
Currently, pcapio is only used by dumpcap, which is only compiled
if there is pcap support. However, making pcapio independent from
libpcap allows it also to be used from text2pcap, which does not
rely on libpcap....

7e84abf0 12/20/2012 09:53 AM Michael Tüxen

Add ws_fclose(), ws_fflush(), and ws_fdopen() to the fileutils.
Retire libpcap_fdopen(), libpcap_dump_flush(), and libpcap_dump_close().

svn path=/trunk/; revision=46636

10dbe80c 12/19/2012 03:27 PM Michael Tüxen

Add support for writing the flags option in the enhanced
packet block (pcapng).

svn path=/trunk/; revision=46619

2977bde9 12/18/2012 06:58 AM Anders Broman

- Make dumpcap build with the new bundle.
- Use the correct bundle id for GTK3

svn path=/trunk/; revision=46586

20211340 12/11/2012 10:25 PM Jeff Morriss

Make the "-g" argument to tshark actually work (by passing it to dumpcap).

svn path=/trunk/; revision=46515

05ee001d 12/11/2012 09:07 PM Jeff Morriss

Document the "-g" option to dumpcap.

Add that option to tshark, too, and document it.

The option can't be given to Wireshark because the GUI already has a "-g"
(goto packet).

svn path=/trunk/; revision=46513

0537be2e 12/10/2012 06:53 PM Stephen Fisher

Change variable "devname" to "devicename" in numerous places to avoid
to avoid -Wshadow warnings about conflicting with BSD's devname()
function.

svn path=/trunk/; revision=46494

552323e7 11/25/2012 01:35 PM Bill Meier

Fix a number of [-Wshadow] warnings;
Also: Do some minor whitespace changes

svn path=/trunk/; revision=46182

bd976ae6 11/22/2012 01:02 AM Guy Harris

On UN*X, if an interface has a description, use it as the "friendly
name". If it doesn't have a description, on OS X, use the System
Configuration framework to attempt to get a "friendly name" for
interfaces.

If a loopback device doesn't have a friendly name, give it "Loopback" as...

d415d3d8 11/21/2012 12:14 PM Guy Harris

On error, have capture_opts_trim_iface() return the exit status that
should be used (on success, have it return 0). Exit with that exit
status; if the problem is that we couldn't get the interface list or if
there are no interfaces in that list, return 2, as that's not a...

03f4fa52 11/21/2012 11:05 AM Guy Harris

Make the "Invalid capture filter" message resemble that of other programs.

svn path=/trunk/; revision=46107

28474fe8 11/19/2012 03:07 PM Anders Broman

From Mike Garratt:
Friendly Names for interfaces on Windows

Notes on the changes the patch covers:
  • if_info_t struct: addition of friendly_name
  • Dumpcap Interface list format changes:
    + Win32: "dumpcap -D" shows friendly_name in place of descript if known...
68aeb27b 10/03/2012 11:42 AM Bill Meier

(Trivial): update a comment.

svn path=/trunk/; revision=45287

3551a86c 09/19/2012 09:29 PM Jeff Morriss

We always HAVE_CONFIG_H so don't bother checking whether we have it or not.

svn path=/trunk/; revision=45015

bcf6e795 09/09/2012 09:57 AM Evan Huus

Convert inpkts_to_sync_pipe and report_packet_count() to use unsigned ints
consistently. Cleans up some cppcheck warnings about signed/unsigned mismatches
in format strings.

svn path=/trunk/; revision=44818

11c86ec4 07/25/2012 03:08 AM Michael Tüxen

Update recv/drop counters also when no threads are used.
This should fix
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7523

svn path=/trunk/; revision=43981

bf81b42e 06/28/2012 06:56 PM Jakub Zawadzki

Update Free Software Foundation address.

(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536

2851255f 06/27/2012 01:13 AM Guy Harris

Don't supply a fallback error message for pcap_open() unless it actually
fails.

This may clear up the problem most recently reported in bug 7021 after
the crash was fixed, where the capture starts successfully but an error
dialog pops up.

svn path=/trunk/; revision=43501

2b6b0656 06/24/2012 03:45 PM Jörg Mayer

Pontus Fuchs via bug 6973:

Add last piece of the wireless toolbar: Use dumpcap to actually set
the channel.

svn path=/trunk/; revision=43466

3685b4db 06/21/2012 09:23 AM Jörg Mayer

Remove some trailing whitespace

svn path=/trunk/; revision=43425

1b0a5c58 06/18/2012 05:50 PM Michael Tüxen

Fix compilation on FreeBSD.

svn path=/trunk/; revision=43343

c3dadc73 06/08/2012 11:36 PM Chris Maynard

Fix Coverity CID 708961: Resource leak, by closing the socket if the connect() fails. While there, print a human-readable error message on Windows like we do for other platforms. Lastly, be sure to specify FORMAT_MESSAGE_IGNORE_INSERTS in the dwFlags arg to all FormatMessage() calls where FORMAT_MESSAGE_FROM_SYSTEM is also specified. (Ref: http://blogs.msdn.com/b/oldnewthing/archive/2007/11/28/6564257.aspx)...