NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Socket.Bind

Associates a socket with an end point.

[Visual Basic]
Public Function Bind( _
   ByVal localEP As EndPoint _
) As Integer
[C#]
public int Bind(
   EndPoint localEP
);
[C++]
public: int Bind(
   EndPoint* localEP
);
[JScript]
public function Bind(
   localEP : EndPoint
) : int;

Parameters

localEP
The end point to associate with the socket.

Return Value

0 if the socket was successfully bound; otherwise, returns a non-zero error code.

Remarks

Bind must be called before Listen.

Requirements

NGWS Runtime Security:

NetworkAccess.Accept The end point referenced in localEP must have accept permission.

Example [C#]

If the socket cannot be bound to the end point, Bind will return a non-zero value indicating the error. The following code attempts to bind a socket to an end point. If the bind attempt is unsuccessful, the error code is written to the console.

[C#]

result = aSocket.Bind(anEndPoint);
if (result <> 0)
{
   Console.WriteLine("Winsock error: " + Convert.ToString(Marshal.GetLastWin32Error()) );

}

See Also

Socket Class | Socket Members | System.Net.Sockets Namespace