Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void loginb_Click(object sender, EventArgs e)
- {
- String username = this.textBox1.Text;
- String password = textBox2.Text;
- String server;
- if (username.Equals("Lolmewn"))
- {
- server = "localhost";
- }
- else
- {
- server = "77.251.20.228";
- }
- //start connecting
- Encoding ASCII = Encoding.ASCII;
- Byte[] RecvBytes = new Byte[256];
- IPEndPoint hostEndPoint;
- IPAddress hostAddress = null;
- int conPort = 3456;
- // Get DNS host information.
- IPHostEntry hostInfo = Dns.GetHostEntry(server);
- // Get the DNS IP addresses associated with the host.
- IPAddress[] IPaddresses = hostInfo.AddressList;
- // Evaluate the socket and receiving host IPAddress and IPEndPoint.
- for (int index = 0; index < IPaddresses.Length; index++)
- {
- hostAddress = IPaddresses[index];
- hostEndPoint = new IPEndPoint(hostAddress, conPort);
- Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
- if (!s.Connected)
- {
- continue;
- }
- s.Send(ASCII.GetBytes("un=" + username + ";pw=" + password));
- Int32 bytesGet = s.Receive(RecvBytes, RecvBytes.Length, 0);
- String get = ASCII.GetString(RecvBytes, 0, bytesGet);
- if (!get.Equals("allow"))
- {
- return;
- }
- else
- {
- loginb.Visible = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement