[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] PHP-Novice, PING??



On Sat, Oct 3, 2009 at 3:40 PM, Jesper K. Pedersen <sslug@sslug> wrote:

> On Sat, 3 Oct 2009 15:24:59 +0200
> Søren Sørensen <sslug@sslug> wrote:
>
> > Hej liste.
> > Jeg er stort set ny og uprøvet i PHP, men jeg har brug for at kunne
> > pinge en række computere i et netværk engang imellem, og jeg prøver
> > foreløbig at få noget til at virke, som jeg har sakset fra
> > www.planet-source-code.com.
> >
> > En del af koden er:
> >
> > $socket = socket_create(AF_INET, SOCK_RAW, 1);
> >     echo "Trying to connect<br>";
> >     if( socket_connect($socket, "www.shs-consult.dk", null))
> >       {
> >       echo "Socket connected<br>";
> >       // If you're using below PHP 5, see the manual for the
> > microtime_float // function. Instead of just using the m
> >       //     icrotime() function.
> >       $startTime = microtime(true);
> >       socket_send($socket, $package, strLen($package), 0);
> >       if (socket_read($socket, 255)) {
> >       echo round(microtime(true) - $startTime, 4) .' seconds';
> >       }
> >     else echo "Socket didn't connect<br>";
> >     }
> >
> > Det siger godt nok "Trying to connect", men derefter siger den
> > INGENTING, hverken at det lykkedes eller at det ikke lykkedes.
> >
> > I må da gerne se hele linket jeg huggede den fra - det er:
> >
> http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=8&txtCodeId=1786
> >
> > Nogen gode ideer til hvad jeg gør galt?
> >
>
> Der må være noget galt med scriptet du har hentet det fra - for socket
> med typen AF_INET skal altid have en port i socket_connect.
>
> Måske du skulle bare bruge "ping" eksemplet fra php.net?
> Kan findes her : http://dk2.php.net/manual/en/function.socket-create.php
> Se under bruger kommentarer.
>
> Mvh
> JesperKP
>

Jamen selvfølgelig er der da noget galt, ellers ville det virke. Nu var det
umiddelbart det med at jeg slet ikke fik nogetsomhelst efter den der
"socket_connect", hverken OK eller ej. Det skyldes dog sikkert, at
programmet aborteres fordi det kun er root der må lave sådan en
socket_connect. På den anden side set kan jeg da godt lave en ping som
almindelig bruger på min hjemme-linux, så det burde vel kunne lade sig gøre
på en server ude i den store verden også. Det var bare planen det skulle
ligge på min egen hjemmeside hos "servage.net", og der kan jeg ikke blive
root, og kan forresten ikke få c-programmer til at køre.

m.v.h.
Søren


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2009-11-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *