Jump to content

Kerroy

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by Kerroy

  1. I see, and how do I do it in win OS?
  2. How do I do it? (I`m using xampp as server at the moment and soon it will change to linux server (not sure which yet))
  3. Thanks thorpe, it`s working great. another question, it`s working only once, how do I keep it live/online?
  4. Hello Gurus, I`m trying to take a tcpserver.php file and turn it on as a active service into php. I tried to follow the instruction: 'using the CLI.exe, entering 'q- tcpserver.php' (but it just show the content of the file and nothing else), than using the CMD to enter: php q- tcpserver.php (but all I got is a msg saying that 'q-' is not a valid command (internal or external). I`m using windows xp pro, xampp as a server and php 5.3 installed fresh. Help me, how do I do it? :shrug:
  5. New update: I succesfully created the socket and made it listen but I can`t reach it to write into it or read from it. The code I use to creat and write/read is: $host = "192.168.50.20"; // set the variables $port = 9878; //just for exmaple, I can use any port available set_time_limit(0); // no timeout $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");// create socket $result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n"); // bind socket to port if ($result==true){ $result = socket_listen($socket, 3) or die("Could not set up socket listener\n"); // start listening for connections $output= '1234567890'; //just for exmaple, but the string will be 10 chars length $spawn = socket_accept($socket) or die("Could not accept incoming connection\n"); // spawn another socket to handle $result = socket_write($spawn, $output, strlen ($output)) or die("Could not write output\n"); if ($result == false){ echo "something went wrong. could not write to socket"; } $input = socket_read($spawn, 1024) or die("Could not read input\n"); // read client input echo "input: ".$input; //just to make sure it`s reading right socket_close($spawn); socket_close($socket); The problems are: 1) it can creat the socket but only as listener. 2) I can`t get to read or write. 3) it doesn`t close the socket. any help, Please?????
  6. Hi jl5501, as I said. This is the code for rec: $fp = fsockopen("192.168.50.20", "12356", $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $stng = fread($fp, 10); } echo "string: ".$stng; //add to see that it really received what I sent Now I get this err: Warning: fsockopen() [function.fsockopen]: unable to connect to 192.168.50.20:12356 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in C:\xampp\htdocs\rec_tcp.php on line 5 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060) string: I`m sure it`s something I miss or in the code or in the pc/server it self. Please help me
  7. Unfornutly I can`t show the receiving code at the moment but I will sure show it here as soon as I can, including the results of netstat. Are the ports still open or time_wait even after a reset? I tried to reset the pc and still got the same err. How do I solve this problem of socket letency/time_wait?
  8. Hi, There isn`t becuase it can`t bind the socket. It worked once but when I tried to send another string it just stop working, since than I get the same problem: 'unable to bind address...' , 'the connection was fail...'. The weird part is I didn`t change any part of the code before or after it worked and still It`s not working. I tried all the solution I found in the net but nothing.
  9. It`s a device that expecting this string (string of numbers only), it can be send/received in any port so that`s not the problem. jl5501 thanks for the help but one small question how does it help me to over come this communication problem that I can`t even open the socket to send/receive?
  10. I tried several ports all the same. I`m working with xampp (I don`t know if it will help but it sure important info). About the listening I tried many deferent approachs and nothing. I`m totaly lost here, what do I do? Do you have a working code?
  11. Hello all masters and freaks, New here, sorry if I repeat the problem but I didn`t found a solution for it. I`m trying to send a string throught a socket (IP address) in one page/pc and receive the string throught a socket (IP address), I could find many examples but none of them works. I`m working on it for awhile now. My code for sending is: $fp = fsockopen($host, $port, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { fwrite($fp, $out);} and receiving: $fp = fsockopen($host, $port, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { fread($fp, $out);} Please help, anyone.
×
×
  • 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.