php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #33629 Limitation whit UDP socks
Submitted: 2005-07-10 11:44 UTC Modified: 2005-07-10 16:32 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: Whachucallme at gmail dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5CVS-2005-07-10 (dev) OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Whachucallme at gmail dot com
New email:
PHP Version: OS:

 

 [2005-07-10 11:44 UTC] Whachucallme at gmail dot com
Description:
------------
I am translating a MIRC script to a PHP script and almost at the end i noticed after 3days of chatting on #php (quakenet) and searching Google that it isn't possible.

At line 169 of the MIRC script u can see:

sockudp -k rcon 7130 %rcon.ip %rcon.port ????rcon %rcon.challengenumber " $+ %rcon.password $+ " logaddress_add %rcon.myip 7130


when i look at the help file of MIRC under sockudp i find:

UDP is a connection-less protocol, ie. you can send information via UDP to other UDP addresses without needing to connect to them first.
UDP does not guarantee that any information you send will actually reach it's destination, ie. it isn't a reliable protocol. Also, be aware that UDP packets may not arrive in the same order as that in which they were sent. This means that you must perform your own checking to confirm that any data you sent actually reached it's destination properly.
/sockudp [-bntkd] [bindip] <name> [port] <ipaddress> <port> [numbytes] [text|%var|&binvar]
If you specify the -t switch, it forces mIRC to send anything beginning with a & as normal text instead of interpreting it as a binary variable. The -n switch appends a $crlf to the line being sent if it's not a &binvar and if it doesn't already have a $crlf.
The -b switch indicates that you are specifying the numbytes value which is the number of bytes you want sent.
The -k switch forces the socket to stay open, this allows it to listen for data that is sent to its port via UDP. If -k is not specified, the socket is opened, the information is sent to the specified ipaddress and port, and the socket is then closed.
The -d switch means that you specified an ip address as the bind address.
If you specify a socket name that doesn't exist, it is created. If it does exist, the existing socket is used to send the info.
You can also specify the local port number that you wish to use, if it isn't specified, mIRC chooses one randomly.
ipaddress and port specify the destination address to which you want to send information. You can only use an IP address here.
On error: if a /sockudp fails, it sets $sock().wserr to the error value, and triggers the on sockwrite event with $sockerr set.

on 1:udpread:name:commands
The udpread event is triggered when there is info waiting to be read on a UDP socket. You can read this info using the /sockread command.
Note: If this event triggers but no /sockread is performed to attempt to read the buffer, it is assumed that no script exists that is handling this buffer, so it is cleared and the info it contained is lost.


please note that there are 2 ports used here 7130 and %rcon.port there just isn't a way in php to get the same effect. No-one on #php found the sollution and nothing on Google.
Making a PHP matchbot has never been done because it just isn't possible in php to make the connection needed for it.

Reproduce code:
---------------
The IRC script is at http://www.mircscripte.de/dl/scripts.php?cid=2&id=34

What doesn't work is:

	$cmd = "????rcon ". $settings['challenge'] ." \"". $settings['rcon'] ."\" logaddress_add ". $settings['myip'] ." 13";
	if (!$cssocket=fsockopen("udp://".$host .":". $port,7130,$errnr)) { 
		$errmsg="No connection"; 
		return ""; 
	}  

	socket_set_blocking($cssocket,true); 

	fwrite($cssocket,$cmd,strlen($cmd));
	while (!feof($cssocket)) {
		echo fgets($cssocket);
	}
	fclose($cssocket);

Expected result:
----------------
If this would work i would get the log from a Half-life based server

Actual result:
--------------
Timeout

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-10 16:32 UTC] wez@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Please ask support questions elsewhere.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 15 06:01:33 2024 UTC