Dan Violet Sagmiller (He/Him)
asked on
java.net.SocketOutputStream cannot be cast to java.io.DataOutputStream
I built a proxy server processing data for MineCraft.
The proxy program works by itself, and I was able to use it to transfer connections to websites or Minecraft servers. Both worked without issue.
However, now I am trying to read the packets, and it requires that I turn the java.net.SocketOutputStrea m into a Java.io.DataOutputStream.
Casting does not work, nor does:
to = new DataOutputStream(outgoing. getOutputS tream()); // throws the error in the title.
I'm very skilled in C#, but just learning Java. how can I convert this stream? - I'm presuming I just need to know the right casting path though another layer/command.
The proxy program works by itself, and I was able to use it to transfer connections to websites or Minecraft servers. Both worked without issue.
However, now I am trying to read the packets, and it requires that I turn the java.net.SocketOutputStrea
Casting does not work, nor does:
to = new DataOutputStream(outgoing.
I'm very skilled in C#, but just learning Java. how can I convert this stream? - I'm presuming I just need to know the right casting path though another layer/command.
ASKER
Ah, thanks for the clarification.
I have a java.net.Socket, and the object I'm using is expecting java.io.DataOutputStream.
I have a java.net.Socket, and the object I'm using is expecting java.io.DataOutputStream.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have no idea why I was getting that error before, but it does appear to be working now. There must have been another part that was affecting it, part of the code I didn't post. But most of it is changed now, so I won't be able to figure out what the problem was.
Thanks for your help.
Thanks for your help.
Not a problem, glad to help!
PrintStream printStream = new PrintStream(socket.getOutp
printStream.print("JOIN #channel1\r\n");
printStream.flush( );
printStream.print("JOIN #channel2\r\n");
printStream.flush( );
Please, elaborate on what you want to achieve