Beej's Guide Network to Programming series serialization 01

Source: Internet
Author: User

At the beginning:

Bytes --------------------------------------------------------------------------------------
This translation is not a standard one-word translation!

It is a product of understanding as a programmer!
If you are interested, you can use your email to communicate with me! (Welcome to your discussion)

My mailbox: veic_2005 # 163.com( replace # @)
------------------------------------------------------------------ Perfect split line --

Copyright:

Beej's Guide Network to Programming
Using Internet Sockets
 
Brian "Beej Jorgensen" Hall
Beej@beej.us
 
Version 3.0.14
September 8, 2009
 
Copyright©2009 Brian "Beej Jorgensen" Hall

 

1. Introduction
Alas! Is Socket programming frustrating to you? Is it difficult to obtain useful information from man pages? But you are overwhelmed by the bind () structure before calling connect? Wait...

Fortunately, I have completed these tasks and I will share my knowledge with everyone. If you understand the C language and want to pass through the swamp of network programming, you are right.

I finally caught up with the future (at the last moment) and updated the IPv6 guide! Enjoy!

1.1 audience

This document is a guide rather than a reference book. If you are new to socket programming and want to find an entry book, you are my reader. But this is not a complete socket programming book.

1.2 platform and Compiler

Most of the Code in this document is successfully compiled on the Linux platform PC using GNU gcc.

1.3 Official Website

Http://beej.us/guide/bgnet/

1.4 attention should be paid to Solaris/SunOS programmers

When compiling on Solaris or SunOS, you must have more parameters. As shown below:

$ Cc-o server. c-lnsl-lsocket-lresolv

1.5 Windows programmer's note

You must add the following header file (unless you have installed Cygwin)

# Include <winsock. h>

In addition, WSAStartup () must be called first, as shown below:

# Include <winsock. h>

...

{

WSADATA wsaData; // if this doesn't work

// WSData wsaData; // then try this instead

// MAKEWORD (1, 1) for Winsock 1.1, MAKEWORD (2, 0) for Winsock 2.0:

If (WSAStartup (MAKEWORD (1, 1), & wsaData )! = 0 ){

Fprintf (stderr, "WSAStartupfailed. \ n ");

Exit (1 );

}

}

 

Finally, you must call WSACleanup ().


End.

From the column xiaobin_HLJ80
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.