Difference between revisions of "Visual Studio Network Programming"

From Minor Miracle Software
Jump to: navigation, search
 
(No difference)

Latest revision as of 12:57, 18 June 2019

Visual Studio Network Programming
CSocket Class is the real way to program sockets in Windows. Needs MFC. Study this later. Uses #include <afxsock.h> with no modification to Slaving App.

Getting Started with Winsock[1]

[2]

Lib: Ws2-32.lib

  • Winsock2.h

Includes core elements from windows.h. If the whole windows.h file is needed the WIN32_LEAN_AND_MEAN macro must be defined in the first line.

  • Initializing Winsock

WSAStartup initializes the Ws2_32.lib and returns a WSADATA struct describing the library. The char string wsaData.szDescription holds the revision, "WinSock 2.0", for example. The wVersion holds the revision number initialized. It will initialize up to the version specified in the first parameter. The wHighVersion hold the highest version supported. Use LOBYTE and HIBYTE macros to decode, in that order.

Use WSAGetLastError for socket errors.

Connecting to a Socket[3]

Internal Links

Parent Article: Visual Studio Notes