Cache Socket Client / Java Server
Hi,
I have to create to a web socket client, but I'm unable to read any data from the server, after flushing the buffer. I have no access to the server, only two examples for the client, one in java and the other one in php:
java example:
socket = new Socket("192.168.0.1", 2003);
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
out.writeUTF("aPassword");
out.writeInt(websiteId);
out.flush();
DataInputStream in = new DataInputStream(socket.getInputStream());
int orderId = in.readInt();
in.close();
out.close();
socket.close();
php:
$this->socket = socket_create(AF_INET, SOCK_STREAM, 0);
$this->writeStr($password);
$this->writeInt($id);
and the write functions are:
public function writeInt($value){
$value = intval($value);
return $this->write(pack('N', $value));
}
public function writeStr($str){
if (is_null($str))
$str = 'null';
$str = strval($str);
$utfString = utf8_encode($str);
$length = strlen($utfString);
return $this->write(pack('n', $length).$utfString);
}
The client I'm creating:
set id=57
set host = "89.73.132.83" set port = 2021
set password="1...5"
set sock.TranslationTable="UTF8"
do sock.Write($$bl(57)_57, 0, .sc)
do sock.Flush(.sc)
set res=sock.ReadAny(12345, -1, .sc)
The socket opens successfully, I suppose there is a problem with the write command.
Any help would be appreciated.