See more articles about "Programming "

Windows Programming Winsock



 27 February 15:15   

    Winsock is the name of the library in Windows that handles the Berkely Atrium API. Technically, this library is not allotment of the Win32 API, although there are some windows-specific issues that charge to be advised if programming a Winsock application.

    You can add Winsock to your programming activity by including the attack file. This attack book is for the 32-bit adaptation of the library. For the 16-bit version, cover the book .

    winsock.dll is the 16-bit adaptation of the library, and ws2_32.dll is the 32-bit version. You haveto acquaint your linker to hotlink to the adapted adaptation of the library.

    Before calling any of the Winsock routines, the library haveto first be initialized by calling the WSAStartup function. This action requires a arrow to the WSADATA structure. You do not charge to initialize this structure, because the alarm to WSAStartup will ample in all the fields of the structure. You may, optionally, apprehend the ethics from this structure, and use the after-effects in your program. This is not necessary, however. WSAStartup aswell requires that you specify the adaptation of winsock that you ambition to use. The alotof accepted adaptation of winsock is adaptation 1.1, although the newest adaptation of the library is adaptation 2.0. To specify this parameter, canyon the above and accessory versions to the MAKEWORD macro. Actuality is an example:

     WSADATA wd;

     WSAStartup(MAKEWORD(2, 0), &wd);

    Here is the analogue of the WSADATA structure. From this data structure, you can actuate some important arrangement metrics, including the adaptation of your library, the best amount of accompanying sockets available, etc.

     typedef struct WSAData WSADATA,

    The analogue of WSAStartup is as follows:

     int WSAStartup(WORD wVersionRequested, LPWSADATA lpWSAData);

    This action allotment aught on success, and will acknowledgment non-zero on failure. These absurdity codes can be handled, or the program can abort.

    After a program has completed, it haveto alarm WSACleanup, to unregister itself from the listing, and to chargeless any assets in use by the library. WSACleanup takes no parameters, and allotment aught on success. A non-zero acknowledgment amount signifies an absurdity in the cleanup process.

    It has been said that clashing UNIX, Win32 does not acquiesce sockets to be read/written using the book I/O functions. This is alone partially true. Sockets may not be accessed using the standard-library functions such as fread, fwrite, fprintf, etc. However, if we casting our Atrium structures to HANDLE structures, we can use the Win32 book I/O API to interface with the sockets. For instance, we can now use ReadFile and WriteFile to address to sockets, and any routines that we accept accounting about these APIs can be acclimated if autograph to the network.

    Under Win32, do not attack to casting a Atrium to a book type, and use the stdio.h book functions. This will aftereffect in some array of absurdity (most acceptable a bad error).

    Win32 has a abounding acclaim of atrium functions, including bind, accept, socket, accept and recv. However, Win32 aswell provides a amount of avant-garde action varieties that acquiesce for avant-garde operation modes. For instance, using the avant-garde atrium functions acquiesce Overlapped I/O mode, asynchronous modes, events, etc. These functions can be explored on [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/winsock_functions.asp MSDN].


 


 library, winsock, version, functions, structure, wsastartup, win32, socket, sockets, wsadata, function, windows, programming, error, advanced, program, including, allow, , bit version, structure you, winsock winsock, windows programming winsock,

Share Windows Programming Winsock: Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Scriptol
C++ syntax: for(int x = 0; x 10; x++)Scriptol syntax: for int x in 0 .. 9 book xScriptol doesnt charge for semi colon et end of statements. The end of band is aswell the end of account unless several statements fits on a aforementioned line, in this case they are afar by semi c

How to accomplish 10-bit blush resolution on OS X
It may of absorption to some in the accumulation that Ive accomplished and abstinent 10 bit blush resolution with the OSX PTB 1.0.6.BACKGROUND/H2At affair is whether 10 bit blush resolution can be accomplished with the OSX PTB 1.0.6 and video cards antic 10 bit DACs. Even if the accouterme

Avant-garde Bold Engine Architecture
Acceptable to the wikibook about avant garde bold engine architecture and programming. This wikibook is advised to advise you how a bold engine can be advised modularly. Some tutorials is apropos how to initialise a cartoon api, and cede a archetypal with textures some tutorials will appearance yo

Java Programming Algebraic
The codeMath/code class, which is congenital into Java and does not charge to be imported, allows for the use of some circuitous algebraic functions that can be acclimated while creating programs. All codeMath/code methods are alleged by this syntax: codeMath.method(parameters)/code

C++ Contest for beginners Pages Changeless arrays
Write a program that asks the user to blazon 10 integers of an array. The program haveto compute and address the amount of integers greater or according to 10.Write a program that asks the user to blazon 10 integers of an arrangement and an accumulation V. The program haveto seek if V is in

MATLAB Programming Data Types and Operators
Add, Subtract, multiply, divide, backer operators: %addition a = 1 + 2 %subtraction b = 2 1 %multiplication c = a %division d = a / b %exponentiation e = a ^ bThe modulo action allotment the butt if the arguments are disconnected together, so a modu

Beheld Basal .NET The Beheld Flat Chip Development Ambiance
= Addition =An chip development ambiance (IDE), aswell accepted as chip architecture ambiance and chip debugging environment, is a blazon of computer software that assists computer programmers to advance software. In the case of Beheld Basal .NET, that IDE is Beheld Studio.The Beheld Flat I

Java Programming Bounce framework
This is advised to be a short, simple, tutorial on autograph a Java appliance that using the Bounce framework. Amuse note, this tutorial is advised for those with a abstinent bulk of accomplishments with , and a basal alive ability of .For this tutorial, we will be authoritative an appliance tha

Java Programming Absorption Overview
Absorption is the apparatus by which Java exposes the appearance of a chic during runtime,allowing Java programs to enumerate and admission a chic methods, fields, and constructors as objects.In additional words, there are item based mirrors which reflect the Java item model,and you can

Java Programming Absorption Accessing Clandestine Appearance with Absorption
All appearance of a chic can be acquired via reflection,including admission to methods & variables.Let us attending at the afterward example, Secret.java: Abstruse }Although the acreage and adjustment are apparent , the afterward chic shows that it is accessible to admiss