title: Android Web Service Implememnation
body: <pre><code>package com.login.android;
  
  import java.net.InetSocketAddress;
  import java.net.Socket;
  import java.nio.ByteBuffer;
  import java.nio.channels.SocketChannel;
  
  import com.login.android.R;
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  
  public class login extends Activity {
      // Declare our Views, so we can access them later
      private EditText etUsername;
      private EditText etPassword;
      private Button btnLogin;
      private Button btnCancel;
      private TextView lblResult;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          // Set Activity Layout
          setContentView(R.layout.main);
  
          // Get the EditText and Button References
          etUsername = (EditText)findViewById(R.id.username);
          etPassword = (EditText)findViewById(R.id.password);
          btnLogin = (Button)findViewById(R.id.login_button);
          btnCancel = (Button)findViewById(R.id.cancel_button);
          lblResult = (TextView)findViewById(R.id.result);
  
          // Set Click Listener
          btnLogin.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  // Check Login
                  SocketChannel sock = SocketChannel.open(new InetSocketAddress("www.abcd.com", 80));
  
                  String data = etUsername + "|" + etPassword;
                  sock.write(ByteBuffer.wrap(data.getBytes()));
  
                  ByteBuffer result = ByteBuffer.allocate(8); // 8 byte-large container for result
                  fSocket.read(result);
  
                  if (result.get(0) == 1)
                           {
                                            lblResult.setText("Login successful.");
  
                      } else {
  
                                     lblResult.setText("Login failed. Username and or password doesn't match.");
                  }
              }
              });
  
          btnCancel.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  // Close the application
                  finish();
              }
          });
      }
  }
  </code></pre>
  
  <p>When I run this I get <code>fSocket</code> error. <code>FSocket cannot be resolved</code>. Kindly tell me what is the mistake I have made here.</p>