#33629 [NEW]: Limitation whit UDP socks
| From: | Whachucallme at gmail dot com | Date: | Sun, 10 Jul 2005 09:44:07 +0000 |
| Subject: | #33629 [NEW]: Limitation whit UDP socks | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-81628@lists.php.net to get a copy of this message | ||
From: Whachucallme at gmail dot com
Operating system: any
PHP version: 5CVS-2005-07-10 (dev)
PHP Bug Type: Feature/Change Request
Bug description: Limitation whit UDP socks
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
--
Edit bug report at http://bugs.php.net/?id=33629&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33629&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33629&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33629&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33629&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33629&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33629&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33629&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33629&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33629&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33629&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=33629&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=33629&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33629&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33629&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33629&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33629&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33629&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33629&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33629&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33629&r=mysqlcfg