Hallo
Kann mir jemand bitte diesen c# code in Java umzusetzten. Ich schaffe es einfach nicht ???:L
Danke und Gruss
Kann mir jemand bitte diesen c# code in Java umzusetzten. Ich schaffe es einfach nicht ???:L
Danke und Gruss
Java:
public static void SendCommand(String command)
{
try
{
StreamWriter clientStreamWriter = null;
// hardcoded IP Address for now.....
String onkyoIP = "192.168.1.69";
int length = command.Length;
length++;
int total = length + 16;
char code = (char)length;
// build up packet header and rest of command - followed by <CR> (chr(13))
//
String line = "ISCP\\x00\\x00\\x00\\x10\\x00\\x00\\x00" + code + "\\x01\\x00\\x00\\x00" + command + "\\x0D";
// create a TCP Client - hardcoded port too ....
TcpClient tcpClient = new TcpClient(onkyoIP, 60128);
//get a network stream from server
NetworkStream clientSockStream = tcpClient.GetStream();
// create new writer stream to send the stuff
clientStreamWriter = new StreamWriter(clientSockStream);
// send command to receiver
//
clientStreamWriter.WriteLine(line);
clientStreamWriter.Flush();
clientStreamWriter.Close();
// close the socket
tcpClient.Close();
}
catch (Exception e)
{
// should do something better here... but meh.. it's just for me
Console.WriteLine(e.StackTrace);
}
}