Jump to content

Atrociouss

New Members
  • Posts

    3
  • Joined

  • Last visited

Atrociouss's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm sorry I missread your reply :/ Thanks, you have answered my question
  2. Ohh I see what your saying. Since my output is 0:0 and the last char is '0' then the while loop is stopping. Is there any way around this?
  3. Note: This is mainly a PHP issue, but the java part is a Bukkit plugin. My TCP Server (made in Java) is one that can send and recieve messages/commands from a client like PuTTy. Everything works perfectly in PuTTy, however when I use a small PHP client I made to test commands, it doesn't recieve the complete output. My PHP is as follows <?php echo '<html><body>'; include('config.php'); $service_port = $_GET['sPort']; $address = $_GET['sIP']; $command = null; $args = null; $api = 0; if (isset($_GET['api'])) { $api = 1; } if (!isset($_GET['sMsg'])) { die('No command given'); } else { $command = trim(strtolower($_GET['sMsg'])); if ($command == null || $command == "") { die('No command given'); } if ((strpos($command, ";")) == false) { /* Args check */ //do nothing, no args } else { $args = explode(";", $command); } } $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket === false) { die('Failed to create socket'); } $result = socket_connect($socket, $address, $service_port); if ($result === false) { die('Failed to connect to server'); } $messag = $command; $message = $messag."\n"; $out = ''; socket_write($socket, $message, strlen($message)); $resp = ""; while ($out = socket_read($socket, 2048)) { $resp .= $out; } $response = trim($resp); $rep = array("/", "\\", "-", "_", "(", ")", "'", "|", "Welcome! Please input the password.", ","); $stripped = str_replace($rep, "", $response); echo $stripped; socket_close($socket); echo '</body></html>'; ?> and when I send the command /adminsconnected the following Java code is fired by the server if (sent.equalsIgnoreCase("/adminsconnected")) { sendText("0", true); plugin.log.info("adminsConnected"); } public void sendText(String text, Boolean suppress) { try { if (suppress) { this.toClient.writeBytes(text + "\r\n"); } else { this.toClient.writeBytes(getTime() + " - "+text + "\r\n"); } if (!suppress) MainClass.log.info("[bTS] Sent: \"" + text + "\""); } catch (Exception e) { e.printStackTrace(); plugin.log.severe(e.toString() + " - sendText (suppress)"); } } My output from PHP is blank, however I recieve the "adminsConnected" and PuTTy gives "0" (the intended output) I get an error in my console: 18:25:53 [sEVERE] java.net.SocketException: Software caused connection abort: socket write error 18:25:53 [sEVERE] at java.net.SocketOutputStream.socketWrite0(Native Method) 18:25:53 [sEVERE] at java.net.SocketOutputStream.socketWrite(Unknown Source) 18:25:53 [sEVERE] at java.net.SocketOutputStream.write(Unknown Source) 18:25:53 [sEVERE] at java.io.DataOutputStream.writeBytes(Unknown Source) 18:25:53 [sEVERE] at com.atrociouss.BTS.Users.sendText(Users.java:339) 18:25:53 [sEVERE] at com.atrociouss.BTS.Users.ssendText(Users.java:323) 18:25:53 [sEVERE] at com.atrociouss.BTS.Users.run(Users.java:278) 18:25:53 [sEVERE] java.net.SocketException: Software caused connection abort: socket write error - sendText (suppress) I was wondering if this was a server issue, or a client issue and if its a mistake that I simply haven't been able to see because i've been staring at it for so long, or if theres something going terribly wrong with my code and I should start from scratch. Any help appreciated!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.