Talking about the use of Isocket

Source: Internet
Author: User
Tags port number

Environment: Brew sdk3.0 Chinese version + vc6.0
References: Sample Programs Netdiagnostics

Establish a TCP connection with Isocket. The specific steps are as follows:

1. Create a brew application named Mysocket, MIF Select "Network" permissions;
The name is in lowercase is conservative a little bit, in fact, 3.0 already can be distinguished by the case
Socket connection cannot be used without network permissions

2.AEEClsCreateInstance () do not change;

3. Add Isocket_release () to close socket in freeappdata;
This is a situation that is released only once, and can be released elsewhere if needed

4. Call Ishell_createinstance () in Initappdata to create an instance of the Inetmgr interface and handle the failure;
This sentence is very important, must have
Be careful about the use of Ishell
If the program is running on the error, then exit, most likely the problem is here. Set Breakpoint Diagnostics

5. Call Start () in handleevent;
Start is the beginning of the implementation of the function

6.Start (), initialize some of the required custom variables, prepare the data to be sent, call Inetmgr_opensocket (), and handle the failure;

7. If Opensocket succeeds, call Isocket_connect () to establish a TCP socket connection with the network entity (the application will communicate with it);

8. If isocket_connect successful, use gethostbyname () to resolve the target address;
Before here, to set the target IP, port number
IP write directly on the line, in quotation marks, port number such as 8080, written ntohs (8080)

9. If gethostbyname succeeds, call Isocket_write (), handle the exception;
In the case of returning Aee_net_wouldblock, call Isocket_writeable ()

10. The judgment information sends completes;
By comparing the number of bytes transferred and the number of bytes in the original message

11. Call Isocket_read ();
In the case of returning Aee_net_wouldblock, call Isocket_readable ()

10. Receive all data.

Attach the error I often encounter:
0x212:connection attempt timed out
0x216:network Subsystem Unavailable

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.