如何调用socket超级构造函数?

时间:2013-10-31 11:39:24

标签: java sockets constructor superclass

你可以告诉我这个对上层构造函数的调用是否有问题吗? 每次我尝试用这个构造函数创建一个新对象时应用程序崩溃,我已经检查过,我发送的参数是正确的,但仍然崩溃......

package com.example.bulbcontrol2;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;

public class ConnectionTool extends Socket
{   
    private PrintWriter outputData;
    private BufferedReader inputBuffer;
    private String message = null;

    public ConnectionTool(InetAddress host, int port) throws IOException 
    {   
        super(host,port);
        outputData = new PrintWriter(this.getOutputStream(), true);
        inputBuffer = new BufferedReader(new InputStreamReader(this.getInputStream()));
    }
}

例外:

10-31 12:35:56.407: W/dalvikvm(9971): threadid=1: thread exiting with uncaught exception (group=0x41577700) 
10-31 12:35:56.407: E/AndroidRuntime(9971): FATAL EXCEPTION: main 
10-31 12:35:56.407: E/AndroidRuntime(9971): java.lang.RuntimeException: Error receiving broadcast Intent { act=open_connection flg=0x10 } in com.example.bulbcontrol2.AsyncConnection$1@41e3ee90 
10-31 12:35:56.407: E/AndroidRuntime(9971): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:773)

0 个答案:

没有答案