Reply to Re: Ping+Port Routine?

Your name:

Reply:


Posted by Jerry Stuckle on 09/26/05 14:59

Adam wrote:
> Still no luck :-((
>
> I have Ethereal running on both client and server. Both versions
> confirm that:
>
> 1) A request goes out to the server on port 2934. This is around 70
> bytes: A header plus around 30 bytes of data.
> 2) The server responds with a welcome of around 120 bytes.
> 3) This packet duly arrives at the client.
>
> OK - now to the code. I've tried every combination of socket connect &
> write, streams .. you name it ...but here are my two main variations:
>
>
> // Set up the connection ===================
> $remote_host = 'udp://192.168.1.126';
> $remote_port = 2934;
> $timeout = 1;
>
> // This is the outgoing msg (in hex) ==========
> $hello =
> "\x20\x00\x09\x42\x46\x4f\x31\x00\x00\x00\x00\x01\x83\x05\x07\x0d\x12";
>
> // This part embeds the client's IP address (in hex, backwards!)
> // This is what the connecting flight sim appears to send
> $hello .="\x03\x01\xa8\xc0";
>
> // The rest of the data packet:- (sim version etc).
> $hello .= "\x03\x84\x0f\x87\x12\x02\x00\x00";
>
> // The returned data (I should be so lucky!) =====
> $ret = '';
>
> // Open the socket ================
> $socket = fsockopen($remote_host, $remote_port, $errno, $errstr,
> $timeout);
> if (!$socket) {
> echo "Connection Failed - Please check manually."; }
> else {
> // Send the packet ===
> fputs($socket, "$hello");
> // fputs($socket, "$hello\r\n"); // Try with a return? ===
>
> echo "Sent to <b>$remote_host:$remote_port</b><br>";
>
> // So far so good ... the packet gets received
> // by the server (confirmed by sniffer) ...
> // and a reply gets sent to the client IP+port ..
>
> //... BUT ... neither of these appear to work =======
> //$ret = fgets($socket, 64);
> $ret = fread($socket, 2048);
> // Tried all sorts values from 1 to 2048 =====
>
> echo "[" . $ret . "]";
> fclose($socket);
> };
> echo "<hr>Closed";
>
> That's it! H-E-L-P !!! I wonder whether you/anyonecan shed any light
> on this!
>
> Adam.


Adam,

Let's back up a little. I'm wondering if we're looking at the wrong
problem.

A couple of thoughts here. First of all, where are you running the
sniffer? Is it on this machine, or somewhere upstream?

Also, are you using a firewall or a router anyplace? If so, are they
set up properly to pass the incoming data onto your program?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация