Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

Winsock Programmer's FAQ (updated 2001.02.10)


[ Usenet FAQs | Web FAQs | Documents | RFC Index | Counties ]
Archive-name: windows/winsock/programmer-faq
Posting-Frequency: monthly (on or after the 19th)
Last-modified: 2001/02/10
URL: http://www.cyberport.com/~tangent/programming/winsock/
Copyright: (c) 1997-2001 Warren Young
Maintainer: Warren Young <tangent@cyberport.com>
X-Disclaimer: Approval for *.answers is based on form, not content.

See reader questions & answers on this topic! - Help others by sharing your knowledge
What Is The Winsock Programmer's FAQ?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The Winsock Programmer's FAQ is a resurrected and expanded version
    of the original Winsock FAQ by Mark Towfiq.  It is essentially
    a new work, though certain elements of its predecessor are still
    recognizable in the current FAQ.

Where Is The FAQ?
~~~~~~~~~~~~~~~~~
    The online version of the FAQ is located at:

        http://www.cyberport.com/~tangent/programming/winsock/

    If you must read it offline, an archived version is kept at:

        http://www.cyberport.com/~tangent/programming/winsock/wskfaq.zip

    This latter is a zipped version of the complete FAQ, including
    the graphics.  This archive is not kept strictly up to date.  I do
    try to rebuild it for every major update to the page, but I make
    no guarantees.

What's New?
~~~~~~~~~~~
    Activity on the FAQ since the last announcement was posted:

        2001.02.10

            Did another update to the I/O strategies article: I added
            one new heuristic, and made several improvements to the
            existing material.

        2001.02.06

            Did a minor re-write on the I/O strategies article. I
            clarified some my advice on non-blocking sockets (Heuristic
            2), split some information out of the old Heuristic 2 into its
            own item (Heuristic 3, now), and removed some redundant and
            misleading advice about asynchronous sockets from Heuristic
            4. I also added Heuristic 12, on designing your program
            around the protocol.

        2001.01.23

            Made several clarifications to the BSD sockets compatibility
            article.

    This summary excludes typo fixes and updates to the Resources section.

Why is the FAQ Useful?
~~~~~~~~~~~~~~~~~~~~~~
    The core of the FAQ answers all of the common questions, like "how
    do I do a ping", and "where can I get sample code". It continues
    answering questions that may not be common, but whose answers I
    think will be useful to the general population of Winsock programmers.

    There are several other sections in the FAQ:
    
    The Resources section provides pointers to other related web sites,
    pointers to interesting MS Knowledge Base articles, and pointers
    to libraries and controls useful to Winsock programmers.

    The Examples section contains several example programs I
    wrote. Most of them illustrate specific items in the FAQ,
    but there's a growing section of Basic Winsock Programs, which
    will eventually show you how to write a simple program with all
    the various I/O strategies Winsock offers, and also to compare
    various Winsock libraries' programming models.

    The Articles section contains several longish items that didn't fit
    in the main FAQ. I wrote most of them, but I have put others' work
    here. Your contributions are welcome, too.

    Finally, there's the Reviews section, where I review various
    Winsock books and programming tools.

The FAQ's Table of Contents
~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Section 0 - Introduction
        0.1 - The Original Introduction
        0.2 - A Bit About the Maintainer
        0.3 - Legal Stuff
        0.4 - Mirrors
        0.5 - What if your question is not in the FAQ?
        0.6 - Is there a mailing list for FAQ updates?
        0.7 - Language Bias
        0.8 - Protocol Bias
        0.9 - Acknowledgements

    Section 1 - General Winsock Information
        1.1 - What is Winsock?
        1.2 - What's the difference between Winsock and TCP/IP?
        1.3 - What newsgroups and mailing lists exist for Winsock and
            TCP/IP?
        1.4 - How do I get off the Winsock 2 Mailing List?
        1.5 - What versions of Winsock are available?
        1.6 - What does Winsock 2 have that Winsock 1.1 doesn't?
        1.7 - When is the next rev of the specification due out?
        1.8 - Can Winsock speak { DECNet, IPX/SPX, etc. }?

    Section 2 - Issues for New Winsock Programmers
        2.1 - Are there any sample apps on the Net?
        2.2 - Do I need to initialize the WSAData structure before calling
            WSAStartup?
        2.3 - I'm getting link errors when compiling Winsock programs.
            What's wrong?
        2.4 - If I write a Winsock program, will I be able to communicate
            with a Unix Sockets program?
        2.5 - Can I use Winsock with { My Favorite Language }?
        2.6 - Are there any tools available for debugging Winsock
            programs?
        2.7 - How do I get a readable error message from a Winsock error
            number?
        2.8 - Winsock keeps returning the error WSAEWOULDBLOCK. What's
            wrong with my program?
        2.9 - How can I test my Winsock application without setting up a
            network?
        2.10 - What's the proper way to close a TCP socket?
        2.11 - Is it possible to close the connection "abnormally"?
        2.12 - How do I detect when my TCP connection is closed?
        2.13 - How do I detect an abnormal network disconnect?
        2.14 - How can I change the timeout for a Winsock function?
        2.15 - What is peeking (MSG_PEEK), and why is it bad?
        2.16 - What is out-of-band data (MSG_OOB), and why is it bad?
        2.17 - If MSG_PEEK and MSG_OOB are bad, what do I pass for send()
            and recv()'s flags parameter?

    Section 3 - Intermediate Winsock Issues
        3.1 - How do I speak { HTTP, POP3, SMTP, FTP, Telnet, NNTP, etc. }
            with Winsock?
        3.2 - How can I encrypt my TCP stream with SSL/TLS?
        3.3 - How do I get my IP address from within a Winsock program?
        3.4 - What's the proper way to impose a packet scheme on a stream
            protocol like TCP?
        3.5 - I'm writing a server. What's a good network port to use?
        3.6 - What is UDP? What are its limitations?
        3.7 - What is UDP good for?
        3.8 - How do I send a broadcast packet?
        3.9 - Is Winsock thread-safe?
        3.10 - If two threads in an application call recv() on a socket,
            will they each get the same data?
        3.11 - Is there any way for two threads to be notified when
            something happens on a socket?
        3.12 - How do I detect if the modem is connected?
        3.13 - How can I get the local username?
        3.14 - Windows 9x's Dial Up Networking keeps popping up an
            automatic dial window, even when it isn't necessary. Can I
            make it stop?
        3.15 - I've heard that asynchronous sockets are unreliable. Is
            this true?
        3.16 - What is the Nagle algorithm?
        3.17 - When should I turn off the Nagle algorithm?
        3.18 - What is TCP's sliding window?
        3.19 - What is the silly window syndrome?
        3.20 - What is the delayed ACK algorithm?
        3.21 - What platform should I deploy my server on?

    Section 4 - Advanced Winsock Issues
        4.1 - How can I open a raw data socket?
        4.2 - How can I capture packets on a LAN with Winsock?
        4.3 - How can I change the IP or TCP header of a packet?
        4.4 - How can I "ping" another machine with Winsock?
        4.5 - Is it possible to create sockets that map to a DLL rather
            than an application?
        4.6 - How can I get access to the {route, ARP, interface, etc.}
            table?
        4.7 - How do I get the MAC (a.k.a. hardware) address of the local
            Ethernet adapter?
        4.8 - How many simultaneous sockets can I have open with Winsock?
        4.9 - What are the "64 sockets" limitations?
        4.10 - How do I make Winsock use a specific network interface?
        4.11 - What do the FIN_WAIT_x, TIME_WAIT, CLOSE_WAIT and other
            states mean?
        4.12 - What is the { SYN, ACK, FIN, RST } bit?
        4.13 - Is it a bad idea to bind() to a particular port in a client
            program?
        4.14 - What is the TCP window size?
        4.15 - What is the connection backlog?

    Section 5 - Resources
        5.1 - Winsock Libraries and Controls
        5.2 - Samples: Tutorial Code
        5.3 - Samples: Useful Code
        5.4 - Debugging Tools (packet sniffers and shims)
        5.5 - Useful Web Pages
        5.6 - Other FAQs
        5.7 - MS Knowledge Base Articles
        5.8 - Winsock SDKs and Specifications
        5.9 - Miscellaneous

    Section 6 - Examples
        6.1 - Several Basic Winsock Programs
        6.2 - Pinging a Host Using Microsoft's ICMP.DLL
        6.3 - Pinging a Host Using Raw Sockets
        6.4 - How to Pass a Socket Handle in Win32
        6.5 - Getting the Local IP Address
        6.6 - Getting the Network Interface List
        6.7 - How to Get the MAC (a.k.a. "hardware") Address, NetBIOS
            method
        6.8 - How to Get the MAC (a.k.a. "hardware") Address, SNMP method
        6.9 - How to Get the MAC (a.k.a. "hardware") Address, RPC method
        6.10 - Finding the Maximum Number of Open Sockets
        6.11 - How to Get the Local User Name

    Section 7 - Articles
        "Winsock for the Impatient" by Warren Young
        "Which I/O Strategy Should I Use?" by Warren Young
        "How to Use TCP Effectively" by Warren Young
        "The Lame List" by the Winsock Vendor Community
        "Debugging TCP" by Warren Young
        "Winsock's Compatibility With BSD Sockets" by Warren Young
        "WsControl() Revealed" by Tom Sanfilippo
        "CSocket Considered Harmful" by Warren Young
        "Passing Sockets Between Processes" by Warren Young and Frank
            Schmied
        "Dealing with Firewalls" by Warren Young
		"Winsock for Non-Windows Systems" by Warren Young

    Section 8 - Book and Software Reviews

    Section 9 - Glossary

--
Warren Young -- Maintainer of The Winsock Programmer's FAQ
Please, do not send unsolicited commercial email.

User Contributions:

Comment about this article, ask questions, or add new information about this topic:


[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
Warren Young <tangent@cyberport.com>





Last Update March 27 2014 @ 02:12 PM