NetworkBaseCreateSocketAndConnect 方法 (String, Int32) |
命名空间: HslCommunication.Core.Net
public class NetworkMy : NetworkBase { public void CreateSocketAndConnectExample1( ) { // 连接远程的端口 OperateResult<Socket> socketResult = CreateSocketAndConnect( "192.168.0.100", 12345 ); if (socketResult.IsSuccess) { // connect success } else { // failed } } public void CreateSocketAndConnectExample2( ) { // 连接远程的端口,允许设置超时时间,比如1秒 OperateResult<Socket> socketResult = CreateSocketAndConnect( "192.168.0.100", 12345, 1000); if (socketResult.IsSuccess) { // connect success } else { // failed } } public void CreateSocketAndConnectExample3( ) { // 连接远程的端口,允许设置超时时间,比如1秒 OperateResult<Socket> socketResult = CreateSocketAndConnect( new System.Net.IPEndPoint( System.Net.IPAddress.Parse( "192.168.0.100" ), 12345 ), 1000 ); if (socketResult.IsSuccess) { // connect success } else { // failed } } }