Socket non-blocking connection

Source: Internet
Author: User

Non-blocking connections, read and write operations are asynchronous, so you do not need to block otherCodeTo establish a non-blocking connection:
1. Set the clienttype attribute to ctnonblocking in the client socket.
2. Set the servertype attribute to stnonblocking in the server socket.

Read and Write operation events
When sockets wants to connect to read or write, it will generate a read and write operation event to inform your socket. On the client sockets, you can

These events respond. on the server side, scokets can respond to these events in the onclientread or onclientwrite event handle. Windows associated with the socket connection

The cancelength method is used to determine the number of bytes to be sent in the socket at the other end of the connection ).

Use the socket connection to write data using the sendbuf, sendstream, or sendtext method. If you do not need to connect to the socket after sending information through the socket, you can use sendstreamthend

Method of ROP.
Sendstreamthendrop closes the socket connection after writing all the information. It can read information from the stream. If you use sendstream or sendstreamthendrop,

Do not release stream
Object. The socket will automatically release the stream after the connection ends.
Note: sendstreamthendrop will disable an independent customer Connection Service, instead of listening for connections.

 

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.