package com.exa.bullseye;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import java.io.InputStream;
import java.io.OutputStream;
public class WifiReceive extends Activity {
EditText ip;
EditText s_port;
Button connect;
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
setContentView(R.layout.wifireceive);
ip = ((EditText)findViewById(R.id.ip));
s_port = ((EditText)findViewById(R.id.port));
connect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
try {
String address = ip.getText().toString();
InetAddress addr = InetAddress.getByName(address);
int port = Integer.parseInt(s_port.getText().toString());
// Creates a stream socket and connects it to the specified port
// number at the specified IP address. Blocks until the connection succeeds.
Socket socket = new Socket(addr, port);
Toast.makeText(getApplicationContext(), "Socket Connected",
Toast.LENGTH_LONG).show();
socket.close();
}
catch (UnknownHostException e) {
Toast.makeText(getApplicationContext(), "Host not found",
Toast.LENGTH_LONG).show();
}
catch (IOException ioe) {
Toast.makeText(getApplicationContext(), "I/O Exception",
Toast.LENGTH_LONG).show();
}
}
});
}
}