private void ExecuteInternal() { try { WiFiDirectTestLogger.Log( "Starting open socket ({6} {7}) from session with handle {0} on device {1} ({2}), expect socket added on session with handle {3} on device {4} ({5})", socketParameters.SenderSessionHandle, senderWFDController.DeviceAddress, senderWFDController.MachineName, socketParameters.ReceiverSessionHandle, receiverWFDController.DeviceAddress, receiverWFDController.MachineName, socketParameters.Protocol.ToString(), socketParameters.Port ); if (socketParameters.Protocol == WiFiDirectServiceIPProtocol.Tcp) { senderSocketHandle = senderWFDController.AddServiceStreamSocket( socketParameters.SenderSessionHandle, socketParameters.Port ); receiverSocketHandle = receiverWFDController.GetServiceRemoteSocketAdded( socketParameters.ReceiverSessionHandle ); } else if (socketParameters.Protocol == WiFiDirectServiceIPProtocol.Udp) { senderSocketHandle = senderWFDController.AddServiceDatagramSocket( socketParameters.SenderSessionHandle, socketParameters.Port ); receiverSocketHandle = receiverWFDController.GetServiceRemoteSocketAdded( socketParameters.ReceiverSessionHandle ); } else { throw new Exception("Unsupported Protocol!"); } succeeded = true; } catch (Exception e) { WiFiDirectTestLogger.Error("Caught exception while executing service open socket scenario: {0}", e); } }