

If you receive a SocketException, use the SocketException.ErrorCode property to obtain the specific error code. If you want to set your default remote host to a broadcast address, you must first call the SetSocketOption method and set the socket option to SocketOptionName.Broadcast, or Connect will throw a SocketException. If you do call Connect any datagrams that arrive from an address other than the specified default will be discarded. You can use SendTo and ReceiveFrom to synchronously communicate with a remote host. If you are using a connectionless protocol such as UDP, you do not have to call Connect before sending and receiving data.

After you call Connect you can send data to the remote device with the Send method, or receive data from the remote device with the Receive method. If you are using a connectionless protocol, Connect establishes a default remote host. If you are using a connection-oriented protocol such as TCP, the Connect method synchronously establishes a network connection between LocalEndPoint and the specified remote endpoint. This method is typically used immediately after a call to GetHostAddresses, which can return multiple IP addresses for a single host. client->Connect( anEndPoint ) Ĭonsole::WriteLine( "Winsock error: ",Ĭonsole.WriteLine("Connection established")
#NETWORKVIEW ON CLIENT CONNECT CODE#
The following code example connects to a remote endpoint and then verifies the connection. The Socket has been placed in a listening state by calling Listen(Int32).
