Implementation of TCP servers and clients under Windows

Source: Internet
Author: User

Server
1. Initialize WSAStartup (..)
2. Create sockets = Socket (..)
3. Bind port ret = bind (...)
4. Monitor ret = Listen (..)
5. Receive Client connection request S_new = Accept (...) Three times the handshake takes place in this process
6. Send and receive data RET = recv (..) Blocking mode, memory is not enough to store the information sent, block Send ()//non-blocking, depending on the size of buffer space to send the corresponding large data, do not block send ()
ret = Send (..)
7. Close the connection

The difference between a client and a server is that there is no need to bind Port 1. Initialize WSAStartup (..)
2. Create sockets = Socket (..)
3. Connect to the server connect (.. )
4. Send and receive data RET = recv (..) Blocking mode, memory is not enough to store the information sent, block Send ()//non-blocking, depending on the size of buffer space to send the corresponding large data, do not block send ()
ret = Send (..)
5. Close the connection




From for notes (Wiz)

Implementation of TCP servers and clients under Windows

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.