Visual C # create a socket class instance to implement the Hosted version of the socket. After creating a socket instance in Visual C #, You can bind it to the specified endpoint in the network using the bind method of the socket instance, you can also use the connect method to establish a connection to the specified endpoint. After the connection is created, you can use its send or sendto method to send data to the socket. Similarly, you can use its receive or receivefrom method to read data from the socket. After the socket is used, use its shutdown method to disable the socket and use the close method to close the socket. Table 01 and table 02 are common attributes and methods in the socket class and their brief descriptions.
Attribute description
Addressfamily obtains the socket address family.
Available obtains the amount of data that has been received from the network and can be read.
Blocking gets or sets a value indicating whether the socket is in blocking mode.
Connected gets a value indicating whether the socket is connected to a remote resource.
Handle obtains the operating system handle of the socket.
Localendpoint: Obtain the local endpoint.
Protocoltype: Obtain the protocol type of the socket.
Remoteendpoint to obtain the remote endpoint.
Sockettype: Obtain the socket type.
Table 01: common attributes of socket classes and their descriptions
Method description
Accept creates a new socket to process incoming connection requests.
Beginaccept starts an asynchronous request and creates a new socket to accept incoming connection requests.
Beginconnect starts an asynchronous request for network device connection.
Beginreceive starts receiving data asynchronously from the connected socket.
Beginreceivefrom starts receiving data asynchronously from the specified network device.
Beginsend asynchronously sends data to the connected
Beginsendto asynchronously sends data to a specified remote host.
Bind associates the socket with a local endpoint.
Close forces the socket connection to close.
Connect establishes a connection to a remote device.
Endaccept ends asynchronous requests to create a new socket to accept incoming connection requests
Endconnect ends a pending asynchronous connection request.
Endreceive ends the suspended asynchronous read.
Endreceivefrom ends the pending asynchronous reading from a specific endpoint.
Endsend ends the suspended asynchronous sending
Endsendto ends the pending asynchronous sending to the specified location.
Getsocketoption returns the value of the socket option.
Iocontrol sets a low-level operation mode for the socket
Listen places the socket in the listening state.
Poll
Receive receives data from the connected socket.
Receivefrom receives data packets and saves them to the storage source endpoint.
Select determines the status of one or more sockets.
Send sends data to the connected
Sendto sends data to a specific endpoint.
Setsocketoption: set socket options.
Shutdown disables sending and receiving on a socket.
Table 02: common methods and descriptions of socket classes
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