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;
0 if the socket was successfully bound; otherwise, returns a non-zero error code.
Bind must be called before Listen.
NGWS Runtime Security:
NetworkAccess.Accept | The end point referenced in localEP must have accept permission. |
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()) ); }
Socket Class | Socket Members | System.Net.Sockets Namespace