Skip to content

Commit

Permalink
[System] More Socket methods from referencesource
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-safar committed Oct 17, 2016
1 parent 1be62d5 commit c143e55
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 47 deletions.
45 changes: 0 additions & 45 deletions mcs/class/System/System.Net.Sockets/Socket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -844,51 +844,6 @@ public void Connect (string host, int port)
Connect (Dns.GetHostAddresses (host), port);
}

public void Connect (IPAddress[] addresses, int port)
{
ThrowIfDisposedAndClosed ();

if (addresses == null)
throw new ArgumentNullException ("addresses");
if (this.AddressFamily != AddressFamily.InterNetwork && this.AddressFamily != AddressFamily.InterNetworkV6)
throw new NotSupportedException ("This method is only valid for addresses in the InterNetwork or InterNetworkV6 families");
if (is_listening)
throw new InvalidOperationException ();

// FIXME: do non-blocking sockets Poll here?
int error = 0;
foreach (IPAddress address in addresses) {
IPEndPoint iep = new IPEndPoint (address, port);

iep = RemapIPEndPoint (iep);

Connect_internal (m_Handle, iep.Serialize (), out error, is_blocking);
if (error == 0) {
is_connected = true;
is_bound = true;
seed_endpoint = iep;
return;
}
if (error != (int)SocketError.InProgress && error != (int)SocketError.WouldBlock)
continue;

if (!is_blocking) {
Poll (-1, SelectMode.SelectWrite);
error = (int)GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Error);
if (error == 0) {
is_connected = true;
is_bound = true;
seed_endpoint = iep;
return;
}
}
}

if (error != 0)
throw new SocketException (error);
}


public void Connect (EndPoint remoteEP)
{
ThrowIfDisposedAndClosed ();
Expand Down
2 changes: 1 addition & 1 deletion mcs/class/System/Test/System.Net.Sockets/TcpClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void ConnectMultiAny ()
client.Connect (ipAddresses, 1234);
Assert.Fail ("ConnectMultiAny #1");
} catch (SocketException ex) {
Assert.AreEqual (10061, ex.ErrorCode, "ConnectMultiAny #2");
Assert.AreEqual (10049, ex.ErrorCode, "ConnectMultiAny #2");
} catch {
Assert.Fail ("ConnectMultiAny #3");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,7 @@ public void Connect(string host, int port){
Connect(addresses,port);
if(s_LoggingEnabled)Logging.Exit(Logging.Sockets, this, "Connect", null);
}
#endif // !MONO

public void Connect(IPAddress[] addresses, int port){
if(s_LoggingEnabled)Logging.Enter(Logging.Sockets, this, "Connect", addresses);
Expand Down Expand Up @@ -1154,7 +1155,7 @@ public void Connect(IPAddress[] addresses, int port){
if(s_LoggingEnabled)Logging.Exit(Logging.Sockets, this, "Connect", null);
}


#if !MONO
/// <devdoc>
/// <para>
/// Forces a socket connection to close.
Expand Down

0 comments on commit c143e55

Please sign in to comment.