You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
byte[]msg=Encoding.ASCII.GetBytes("This is a test");
29
+
byte[]msg=Encoding.ASCII.GetBytes("This is a test");
30
30
31
-
//<Snippet2>
32
-
Console.WriteLine("This application will timeout if Send does not return within "+Encoding.ASCII.GetString(s.GetSocketOption(SocketOptionLevel.Socket,SocketOptionName.SendTimeout,4)));
31
+
//<Snippet2>
32
+
Console.WriteLine("This application will timeout if Send does not return within "+Encoding.ASCII.GetString(s.GetSocketOption(SocketOptionLevel.Socket,SocketOptionName.SendTimeout,4)));
Console.WriteLine("If data remains to be sent, this application will stay open for "+((LingerOption)s.GetSocketOption(SocketOptionLevel.Socket,SocketOptionName.Linger)).LingerTime.ToString());
Console.WriteLine("If data remains to be sent, this application will stay open for "+((LingerOption)s.GetSocketOption(SocketOptionLevel.Socket,SocketOptionName.Linger)).LingerTime.ToString());
//Using the AddressFamily, SocketType, and ProtocolType properties.
59
-
Console.WriteLine("I just set the following properties of socket: "+"Address Family = "+s.AddressFamily.ToString()+"\nSocketType = "+s.SocketType.ToString()+"\nProtocolType = "+s.ProtocolType.ToString());
58
+
//Using the AddressFamily, SocketType, and ProtocolType properties.
59
+
Console.WriteLine("I just set the following properties of socket: "+"Address Family = "+s.AddressFamily.ToString()+"\nSocketType = "+s.SocketType.ToString()+"\nProtocolType = "+s.ProtocolType.ToString());
60
60
61
-
//</Snippet3>
62
-
//<Snippet4>
63
-
s.Connect(lep);
61
+
//</Snippet3>
62
+
//<Snippet4>
63
+
s.Connect(lep);
64
64
65
65
// Using the RemoteEndPoint property.
66
-
Console.WriteLine("I am connected to "+IPAddress.Parse(((IPEndPoint)s.RemoteEndPoint).Address.ToString())+"on port number "+((IPEndPoint)s.RemoteEndPoint).Port.ToString());
66
+
Console.WriteLine("I am connected to "+IPAddress.Parse(((IPEndPoint)s.RemoteEndPoint).Address.ToString())+"on port number "+((IPEndPoint)s.RemoteEndPoint).Port.ToString());
67
67
68
68
// Using the LocalEndPoint property.
69
-
Console.WriteLine("My local IpAddress is :"+IPAddress.Parse(((IPEndPoint)s.LocalEndPoint).Address.ToString())+"I am connected on port number "+((IPEndPoint)s.LocalEndPoint).Port.ToString());
69
+
Console.WriteLine("My local IpAddress is :"+IPAddress.Parse(((IPEndPoint)s.LocalEndPoint).Address.ToString())+"I am connected on port number "+((IPEndPoint)s.LocalEndPoint).Port.ToString());
70
70
71
-
//</Snippet4>
71
+
//</Snippet4>
72
72
//<Snippet5>
73
-
//Use low level method IOControl to set this socket to blocking mode.
73
+
//Use low level method IOControl to set this socket to blocking mode.
74
74
intcode=unchecked((int)0x8004667E);
75
75
byte[]inBuf=newbyte[4];
76
76
77
77
inBuf[0]=0;
78
78
79
79
byte[]outBuf=newbyte[4];
80
80
81
-
s.IOControl(code,inBuf,outBuf);
81
+
s.IOControl(code,inBuf,outBuf);
82
82
83
-
//Check to see that this worked.
83
+
//Check to see that this worked.
84
84
if(s.Blocking)
85
85
{
86
-
Console.WriteLine("Socket was set to Blocking mode successfully");
86
+
Console.WriteLine("Socket was set to Blocking mode successfully");
0 commit comments