System
[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00]
1.0.3300.0
1.0.5000.0
2.0.0.0
4.0.0.0
Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details.
System.Object
System.IDisposable
The class provides simple methods for connecting, sending, and receiving stream data over a network in synchronous blocking mode.
In order for to connect and exchange data, a or created with the TCP must be listening for incoming connection requests. You can connect to this listener in one of the following two ways:
-
Create a and call one of the three available methods.
-
Create a using the host name and port number of the remote host. This constructor will automatically attempt a connection.
If you want to send connectionless datagrams in synchronous blocking mode, use the class.
Provides client connections for TCP network services.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
This constructor creates a new and allows the underlying service provider to assign the most appropriate local IP address and port number. You must first call the method before sending and receiving data.
This constructor works only with IPv4 address types.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Initializes a new instance of the class.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
This constructor creates a new and binds it to the specified by the parameter. Before you call this constructor, you must create an using the IP address and port number from which you intend to send and receive data. You do not need to specify a local IP address and port number before connecting and communicating. If you create a using any other constructor, the underlying service provider will assign the most appropriate local IP address and port number.
You must call the method before sending and receiving data.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Initializes a new instance of the class and binds it to the specified local endpoint.
The to which you bind the TCP .
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Initializes a new instance of the class with the specified family.
The of the IP protocol.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
This constructor creates a new and makes a synchronous connection attempt to the provided host name and port number. The underlying service provider will assign the most appropriate local IP address and port number. will block until it either connects or fails. This constructor allows you to initialize, resolve the DNS host name, and connect in one convenient step.
If IPv6 is enabled and the method is called to connect to a host that resolves to both IPv6 and IPv4 addresses, the connection to the IPv6 address will be attempted first before the IPv4 address. This may have the effect of delaying the time to establish the connection if the host is not listening on the IPv6 address.
If you receive a , use to obtain the specific error code. After you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation in MSDN for a detailed description of the error.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Initializes a new instance of the class and connects to the specified port on the specified host.
The DNS name of the remote host to which you intend to connect.
The port number of the remote host to which you intend to connect.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
To be added: an object of type 'bool'
Classes deriving from can use this property to determine if a connection attempt has succeeded. It does not monitor the ongoing connection state of . If the remote host closes the connection, will not be updated. If you are deriving from and require closer attention to the connection state, use the property of the returned by the method.
Gets or set a value that indicates whether a connection has been made.
Property
2.0.0.0
4.0.0.0
System.Int32
To be added.
is a way to determine whether data is queued for reading. If data is available, call to get the data. The available data is the total amount of data queued in the network buffer for reading. If no data is queued in the network buffer, returns 0.
If the remote host shuts down or closes the connection, may throw a . If you receive a , use to obtain the specific error code. After you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation in the MSDN library at http://msdn.microsoft.com/library/ for a detailed description of the error.
Gets the amount of data that has been received from the network and is available to be read.
Method
2.0.0.0
4.0.0.0
System.IAsyncResult
The asynchronous operation must be completed by calling the method. Typically, the method is invoked by the delegate.
This method does not block until the operation completes. To block until the operation completes, use one of the method overloads.
For detailed information about using the asynchronous programming model, see Asynchronous Programming Overview.
Begins an asynchronous request for a remote host connection. The remote host is specified by an and a port number ().
An object that references the asynchronous connection.
The of the remote host.
The port number of the remote host.
An delegate that references the method to invoke when the operation is complete.
A user-defined object that contains information about the connect operation. This object is passed to the delegate when the operation is complete.
Method
2.0.0.0
4.0.0.0
System.IAsyncResult
The asynchronous operation must be completed by calling the method. Typically, the method is invoked by the delegate.
This method does not block until the operation completes. To block until the operation completes, use one of the method overloads.
For detailed information about using the asynchronous programming model, see Asynchronous Programming Overview.
This method is typically used immediately after a call to the method, which can return multiple IP addresses for a single host.
Begins an asynchronous request for a remote host connection. The remote host is specified by an array and a port number ().
An object that references the asynchronous connection.
At least one that designates the remote hosts.
The port number of the remote hosts.
An delegate that references the method to invoke when the operation is complete.
A user-defined object that contains information about the connect operation. This object is passed to the delegate when the operation is complete.
Method
2.0.0.0
4.0.0.0
System.IAsyncResult
The asynchronous operation must be completed by calling the method. Typically, the method is invoked by the delegate.
This method does not block until the operation completes. To block until the operation completes, use one of the method overloads.
For detailed information about using the asynchronous programming model, see Asynchronous Programming Overview.
Begins an asynchronous request for a remote host connection. The remote host is specified by a host name () and a port number ().
An object that references the asynchronous connection.
The name of the remote host.
The port number of the remote host.
An delegate that references the method to invoke when the operation is complete.
A user-defined object that contains information about the connect operation. This object is passed to the delegate when the operation is complete.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Net.Sockets.Socket
The .
creates a to send and receive data over a network. Classes deriving from can use this property to get or set this . Use the underlying returned from if you require access beyond that which provides. You can also use to set the underlying to an existing . This might be useful if you want to take advantage of the simplicity of using a pre-existing .
Gets or sets the underlying .
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
The method marks the instance as disposed and requests that the associated close the TCP connection. Based on the property, the TCP connection may stay open for some time after the method is called when data remains to be sent. There is no notification provided when the underlying connection has completed closing.
Calling this method will eventually result in the close of the associated and will also close the associated that is used to send and receive data if one was created.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Disposes this instance and requests that the underlying TCP connection be closed.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
Call this method to establish a synchronous remote host connection to the specified . Before you call you must create an instance of the class using an IP address and a port number. Use this as the parameter. The method will block until it either connects or fails. After connecting with the remote host, use the method to obtain the underlying . Use this to send and receive data.
If you receive a , use to obtain the specific error code. After you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation in MSDN for a detailed description of the error.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>]
Connects the client to a remote TCP host using the specified remote network endpoint.
The to which you intend to connect.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
Call this method to establish a synchronous remote host connection to the specified and port number. The method will block until it either connects or fails. After connecting with the remote host, use the method to obtain the underlying . Use this to send and receive data.
If you receive a , use to obtain the specific error code. After you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation in MSDN for a detailed description of the error.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Connects the client to a remote TCP host using the specified IP address and port number.
The of the host to which you intend to connect.
The port number to which you intend to connect.
Method
2.0.0.0
4.0.0.0
System.Void
This method is typically used immediately after a call to the method, which can return multiple IP addresses for a single host. Call the method to establish a synchronous remote host connection to the host specified by the array of elements and the port number. The method will block until it either connects or fails. After connecting with the remote host, use the method to obtain the underlying . Use this to send and receive data.
If you receive a , use to obtain the specific error code. After you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation in the MSDN library at http://msdn.microsoft.com/library for a detailed description of the error.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Connects the client to a remote TCP host using the specified IP addresses and port number.
The array of the host to which you intend to connect.
The port number to which you intend to connect.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
Call this method to establish a synchronous remote host connection to the specified host name and port number. The method will block until it either connects or fails. After connecting with the remote host, use the method to obtain the underlying . Use this to send and receive data.
If IPv6 is enabled and the method is called to connect to a host that resolves to both IPv6 and IPv4 addresses, the connection to the IPv6 address will be attempted first before the IPv4 address. This may have the effect of delaying the time to establish the connection if the host is not listening on the IPv6 address.
If you receive a , use to obtain the specific error code. After you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation in MSDN for a detailed description of the error.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Connects the client to the specified port on the specified host.
The DNS name of the remote host to which you intend to connect.
The port number of the remote host to which you intend to connect.
Method
4.0.0.0
System.Threading.Tasks.Task
This operation will not block. The returned Returns object will complete after the TCP connection has been established. This method does not block the calling thread while the connection request is underway.
Call this method to establish a synchronous remote host connection to the specified and port number as an asynchronous operation. After connecting with the remote host, use the method to obtain the underlying . Use this to send and receive data.
If you receive a , use to obtain the specific error code. After you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation in MSDN for a detailed description of the error.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Connects the client to a remote TCP host using the specified IP address and port number as an asynchronous operation.
Returns
The task object representing the asynchronous operation.
The of the host to which you intend to connect.
The port number to which you intend to connect.
Method
4.0.0.0
System.Threading.Tasks.Task
This operation will not block. The returned Returns object will complete after the TCP connection has been established. This method does not block the calling thread while the connection request is underway.
This method is typically used immediately after a call to the method, which can return multiple IP addresses for a single host. Call this method to establish a synchronous remote host connection to the host specified by the array of elements and the port number as an asynchronous operation. After connecting with the remote host, use the method to obtain the underlying . Use this to send and receive data.
If you receive a , use to obtain the specific error code. After you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation in the MSDN library at http://msdn.microsoft.com/library for a detailed description of the error.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Connects the client to a remote TCP host using the specified IP addresses and port number as an asynchronous operation.
Returns
The task object representing the asynchronous operation.
The array of the host to which you intend to connect.
The port number to which you intend to connect.
Method
4.0.0.0
System.Threading.Tasks.Task
This operation will not block. The returned Returns object will complete after the TCP connection has been established. This method does not block the calling thread while the connection request is underway.
Call this method to establish a synchronous remote host connection to the specified host name and port number as an asynchronous operation. After connecting with the remote host, use the method to obtain the underlying . Use this to send and receive data.
If IPv6 is enabled and the method is called to connect to a host that resolves to both IPv6 and IPv4 addresses, the connection to the IPv6 address will be attempted first before the IPv4 address. This may have the effect of delaying the time to establish the connection if the host is not listening on the IPv6 address.
If you receive a , use to obtain the specific error code. After you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation in MSDN for a detailed description of the error.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Connects the client to the specified TCP port on the specified host as an asynchronous operation.
Returns
The task object representing the asynchronous operation.
The DNS name of the remote host to which you intend to connect.
The port number of the remote host to which you intend to connect.
Property
2.0.0.0
4.0.0.0
System.Boolean
To be added.
The property gets the connection state of the socket as of the last I/O operation. When it returns false, the socket was either never connected, or is no longer connected.
Because the property only reflects the state of the connection as of the most recent operation, you should attempt to send or receive a message to determine the current state. After the message send fails, this property no longer returns true. Note that this behavior is by design. You cannot reliably test the state of the connection because, in the time between the test and a send/receive, the connection could have been lost. Your code should assume the socket is connected, and gracefully handle failed transmissions.
Gets a value indicating whether the underlying for a is connected to a remote host.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
This method is called by the public Dispose() method and the method. Dispose() invokes this method with the parameter set to true. invokes this method with set to false.
When the parameter is true, this method releases all resources held by any managed objects that this references. It does this by invoking the Dispose() method of each referenced object.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Releases the unmanaged resources used by the and optionally releases the managed resources.
Set to true to release both managed and unmanaged resources; false to release only unmanaged resources.
Method
2.0.0.0
4.0.0.0
System.Void
This method blocks until the operation is complete. To perform this operation synchronously, use a method.
If you receive a , use to obtain the specific error code. After you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation in the MSDN library at http://msdn.microsoft.com/library for a detailed description of the error.
Ends a pending asynchronous connection attempt.
An object returned by a call to .
Property
2.0.0.0
4.0.0.0
System.Boolean
To be added.
By default, multiple clients can use a specific port; however, only one of the clients can perform operations on the network traffic sent to the port. You can use the property to prevent multiple clients from using a specific port.
This property must be set before the underlying socket is bound to a client port. If you call , , , or , the client port is bound as a side effect of the method, and you cannot subsequently set the property
Gets or sets a value that specifies whether the allows only one client to use a port.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
This method overrides . Application code should not call this method; an object's method is automatically invoked during garbage collection, unless finalization by the garbage collector has been disabled by a call to the method.
The class finalizer closes the TCP connection and releases all managed resources associated with the . These resources include the underlying used for connecting with the remote host, and the used to send and receive data. The finalizer does not release any unmanaged resources.
For more information, see [<topic://cpconFinalizeMethodscDestructors>], [<topic://cpconCleaningUpUnmanagedResources>], and [<topic://cpconOverridingFinalizeMethod>].
Frees resources used by the class.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Net.Sockets.NetworkStream
returns a that you can use to send and receive data. The class inherits from the class, which provides a rich collection of methods and properties used to facilitate network communications.
You must call the method first, or the method will throw an . After you have obtained the , call the method to send data to the remote host. Call the method to receive data arriving from the remote host. Both of these methods block until the specified operation is performed. You can avoid blocking on a read operation by checking the property. A true value means that data has arrived from the remote host and is available for reading. In this case, is guaranteed to complete immediately. If the remote host has shutdown its connection, will immediately return with zero bytes.
You must close the when you are through sending and receiving data. Closing does not release the .
If you receive a , use to obtain the specific error code. After you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation in MSDN for a detailed description of the error.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Returns the used to send and receive data.
The underlying .
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Net.Sockets.LingerOption
To be added: an object of type 'LingerOption'
The property changes the way method behaves. This property when set modifies the conditions under which the connection can be reset by Winsock. Connection resets can still occur based on the IP protocol behavior.
This property controls the length of time that the TCP connection will remain open after a call to when data remains to be sent. When you call the method, data is placed in the outgoing network buffer. This property can be used to ensure that this data is sent to the remote host before the method drops the connection.
To enable lingering, create a instance containing the desired values, and set the property to this instance.
The following table describes the behavior of the method for the possible values of the property and the property stored in the property.
-
LingerState.Enabled
LingerState.LingerTime
Behavior
-
false (disabled), the default value
The time-out is not applicable, (default).
Attempts to send pending data until the default IP protocol time-out expires.
-
true (enabled)
A nonzero time-out
Attempts to send pending data until the specified time-out expires, and if the attempt fails, then Winsock resets the connection.
-
true (enabled)
A zero timeout.
Discards any pending data and Winsock resets the connection.
The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a socket when the property is not set.
When the property stored in the property is set greater than the default IP protocol time-out, the default IP protocol time-out will still apply and override.
Gets or sets information about the linger state of the associated socket.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
To be added: an object of type 'bool'
When is false, a does not send a packet over the network until it has collected a significant amount of outgoing data. Because of the amount of overhead in a TCP segment, sending small amounts of data is inefficient. However, situations do exist where you need to send very small amounts of data or expect immediate responses from each packet you send. Your decision should weigh the relative importance of network efficiency versus application requirements.
Gets or sets a value that disables a delay when send or receive buffers are not full.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
The buffer size.
The property gets or sets the number of bytes that you are expecting to store in the receive buffer for each read operation. This property actually manipulates the network buffer space allocated for receiving incoming data.
Your network buffer should be at least as large as your application buffer to ensure that the desired data will be available when you call the method. Use the property to set this size. If your application will be receiving bulk data, you should pass the method a very large application buffer.
If the network buffer is smaller than the amount of data you request in the method, you will not be able to retrieve the desired amount of data in one read operation. This incurs the overhead of additional calls to the method.
Gets or sets the size of the receive buffer.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
To be added: an object of type 'int'
The property determines the amount of time that the method will block until it is able to receive data. This time is measured in milliseconds. If the time-out expires before successfully completes, throws a . There is no time-out by default.
Gets or sets the amount of time a will wait to receive data once a read operation is initiated.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
The buffer size.
The property gets or sets the number of bytes that you are expecting to send in each call to the method. This property actually manipulates the network buffer space allocated for send operation.
Your network buffer should be at least as large as your application buffer to ensure that the desired data will be stored and sent in one operation. Use the property to set this size. If your application will be sending bulk data, you should pass the method a very large application buffer.
If the network buffer is smaller than the amount of data you provide the method, several network send operations will be performed for every call you make to the method. You can achieve greater data throughput by ensuring that your network buffer is at least as large as your application buffer.
Gets or sets the size of the send buffer.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
To be added: an object of type 'int'
The property determines the amount of time that the method will block until it is able to return successfully. This time is measured in milliseconds.
After you call the method, the underlying returns the number of bytes actually sent to the host. The property determines the amount of time a will wait before receiving the number of bytes returned. If the time-out expires before the method successfully completes, will throw a . There is no time-out by default.
Gets or sets the amount of time a will wait for a send operation to complete successfully.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
Call when you are finished using the . The method leaves the in an unusable state. After calling , you must release all references to the so the garbage collector can reclaim the memory that the was occupying. For more information, see [<topic://cpconCleaningUpUnmanagedResources>] and [<topic://cpconImplementingDisposeMethod>].
Note: Always call before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's Finalize method.
Releases all resources used by the .