Mynet.cs
Using system.net.sockets; using system.net;
Namespace MyNet {///
New public void connect (system.net.endpoint endpoint) {// If the connection is unsuccessful, the following base.connect () will be wrong, so add try try {base.connect (endpoint); do {if (this. "{OnConnect (this, new evenetargs ()); break;}} while (true);} catch (exception e) {}}
}
Example: Add a Button on Form1
...... using mynet; .......
private void button1_Click (object sender, System.EventArgs e) {MySocket socket = new MySocket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.OnConnect = new MySocket.SocketConnect (this.socket_Connect); IPEndPoint endPoint = New IpendPoint (iPaddress.Parse ("192.168.75.74"), 80); socket.connect (endpoint);
The younger brother is not talented, just want to throw a brick!