Linux C + + socket Server Client

Source: Internet
Author: User
Tags set socket
1. Create a simple socket programming process as follows for connected socket programming Server: 1) Create socket (socket) 2) bind socket to a local address and port (BIND) 3) set socket to listen mode, prepare to accept client request (listen) 4)  Wait for the client request to arrive, when the request arrives, accept the connection request, return a new socket corresponding to this connection (accept) 5) with the returned socket and the client for communication (SEND/RECV), 6) Return, wait for another client to request 7) Close the socket client: 1) Create socket (socket) 2) Make connection request to server (connect) 3) and Server for Communication (SEND/RECV) 4) Close socket
For a non-connected socket programming Server: (receiver) 1) Create socket (socket) 2) bind the socket to a local address and port (BIND) 3) communicate with the client using the returned socket (recvfrom); 4) Close the socket Word client: (sender side) 1) Create socket (socket) 2) Send data to Server (SENDTO3) Close socket

Linux C + + socket Server Client

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.