The error message is saying that msock is uninitialized before the constructor is run. You can't use variables from the child class before you finish the constructor of the parent.
The second version is slightly different since it calls the default superclass constructor (ie the one without any arguments). Also calling
Code:
new DatagramIncoming(msock);
after the first bit of code won't have any effect: it will create a DatagramIncoming object then discard it.
I'm wondering if you need a seperate MulticastSocket variable in your MulticastIncoming class. If you already have a MulticastSocket variable called msock in the parent DatagramIncoming class then you can reference it from the child class. Assuming the constructor for DatagramIncoming sets the MulticastSocket variable, then you could do this:
Code:
...
public MulticastIncoming() throws SocketException, IOException, UnknownHostException
{
super(new MulticastSocket(PORT));
multicastserverIP=InetAddress.getByName(SERVER);
msock.joinGroup(multicastserverIP);
}
...
Of course I'm just guessing about your DatagramIncoming class.