Send binary data to socket

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Quarco

    Send binary data to socket

    Hi,

    Quick & simple question:
    I have to send the next data to a socket in order to make a popup visible on
    a windows machine..

    TITLE Title of popup [enter]
    TEXT Text in popup [enter]
    POPUP [enter]


    <?
    $s=socket_raw_c onnect($host,$p ort,15,'TITLE Test \nTEXT Text in
    popup\nPOPUP\n' );

    function socket_raw_conn ect ($server, $port, $timeout,$reque st) {
    if (!is_numeric($p ort) or !is_numeric($ti meout)) {return false;}
    $socket = fsockopen($serv er, $port, $errno, $errstr, $timeout);
    if(!$socket) { echo "Opening socket error"; exit(); }

    sleep(10); #Wait for program... bug :-)
    $put=fputs($soc ket, $request);
    sleep(10);
    fclose($socket) ;
    }
    ?>

    Now, I have tried the whole scala of \r \n \r\n \0x0a etc.. for \n but it
    doesn't seem to work..

    Anyone a bright idea???


    Thanx in advance,
    Marco




  • Erwin Moller

    #2
    Re: Send binary data to socket

    Hi Marco,

    I fail to see what a popup has to do with a socket.
    Really.
    Are you talking about browser-popup?

    That aside: What do you mean by "doesn't seem to work?"

    Is the socket not accepting connections?
    You didn't create a socket on a port under 1024 on *nix without being root??

    Do you get an error?
    Does the whole thingy time-out?

    Please provide us/me with a little more information.

    Regards,
    Erwin Moller

    Comment

    • Marco

      #3
      Re: Send binary data to socket

      Ok.. Seems the information was too little :-)

      here we go with a little more info:

      A friend of mine as programmed a simple popup kind of thing.
      I made a scheduler in PHP, but to assure we don't forget any todo-items I
      thought it would be a nice feature to let this scheduler (running on LINUX
      server with apache/PHP) send messages to (in this case) my windows machine.
      (e.g: call php page with aid of crontab)

      Now, this friend has a reputation with Delphi (pascal) and programmed a nice
      little popup application.
      To use it I have to connect to (if local) 127.0.0.1 port 12345 (with SSH /
      putty raw connection) and after entering the Tilte of the popup, text and
      the final POPUP command, I see a nice popup with the text I entered...

      ....
      So the commands entered in the PUTTY window are quite simple:
      TITLE Title of popup window
      TEXT text in popup window
      POPUP

      Now what I have to do (in php duh..) is sending these commands to the
      client......... .....
      So my thought would be creating a socket to the (windows) machine with the
      popup-thing running and send the commands..
      But it just doesn't seem to work..

      If anyone of you can help me out.. PLEASE!! :-)

      Thanx in advance,
      Marco




      "Quarco" <dontbother@hot mail.com> schreef in bericht
      news:41b86bfc$0 $566$e4fe514c@n ews.xs4all.nl.. .[color=blue]
      > Hi,
      >
      > Quick & simple question:
      > I have to send the next data to a socket in order to make a popup visible
      > on
      > a windows machine..
      >
      > TITLE Title of popup [enter]
      > TEXT Text in popup [enter]
      > POPUP [enter]
      >
      >
      > <?
      > $s=socket_raw_c onnect($host,$p ort,15,'TITLE Test \nTEXT Text in
      > popup\nPOPUP\n' );
      >
      > function socket_raw_conn ect ($server, $port, $timeout,$reque st) {
      > if (!is_numeric($p ort) or !is_numeric($ti meout)) {return false;}
      > $socket = fsockopen($serv er, $port, $errno, $errstr, $timeout);
      > if(!$socket) { echo "Opening socket error"; exit(); }
      >
      > sleep(10); #Wait for program... bug :-)
      > $put=fputs($soc ket, $request);
      > sleep(10);
      > fclose($socket) ;
      > }
      > ?>
      >
      > Now, I have tried the whole scala of \r \n \r\n \0x0a etc.. for \n but it
      > doesn't seem to work..
      >
      > Anyone a bright idea???
      >
      >
      > Thanx in advance,
      > Marco
      >
      >
      >
      >[/color]


      Comment

      • Chung Leong

        #4
        Re: Send binary data to socket

        "Quarco" <dontbother@hot mail.com> wrote in message
        news:41b86bfc$0 $566$e4fe514c@n ews.xs4all.nl.. .[color=blue]
        > Hi,
        >
        > Quick & simple question:
        > I have to send the next data to a socket in order to make a popup visible[/color]
        on[color=blue]
        > a windows machine..
        >
        > TITLE Title of popup [enter]
        > TEXT Text in popup [enter]
        > POPUP [enter]
        >
        >
        > <?
        > $s=socket_raw_c onnect($host,$p ort,15,'TITLE Test \nTEXT Text in
        > popup\nPOPUP\n' );
        >
        > function socket_raw_conn ect ($server, $port, $timeout,$reque st) {
        > if (!is_numeric($p ort) or !is_numeric($ti meout)) {return false;}
        > $socket = fsockopen($serv er, $port, $errno, $errstr, $timeout);
        > if(!$socket) { echo "Opening socket error"; exit(); }
        >
        > sleep(10); #Wait for program... bug :-)
        > $put=fputs($soc ket, $request);
        > sleep(10);
        > fclose($socket) ;
        > }
        > ?>
        >
        > Now, I have tried the whole scala of \r \n \r\n \0x0a etc.. for \n but it
        > doesn't seem to work..
        >
        > Anyone a bright idea???[/color]

        A firewall blocking the connection? What port are you using?

        BTW: I hope you're not writing an adware.


        Comment

        • Marco

          #5
          Re: Send binary data to socket =&gt; solve

          Seemed the app. expected a timout between the commands..


          No, it is _not_ an ad aware whatsoever :-)


          "Chung Leong" <chernyshevsky@ hotmail.com> schreef in bericht
          news:nb-dnciOxoA6cSXcRV n-pA@comcast.com. ..[color=blue]
          > "Quarco" <dontbother@hot mail.com> wrote in message
          > news:41b86bfc$0 $566$e4fe514c@n ews.xs4all.nl.. .[color=green]
          >> Hi,
          >>
          >> Quick & simple question:
          >> I have to send the next data to a socket in order to make a popup visible[/color]
          > on[color=green]
          >> a windows machine..
          >>
          >> TITLE Title of popup [enter]
          >> TEXT Text in popup [enter]
          >> POPUP [enter]
          >>
          >>
          >> <?
          >> $s=socket_raw_c onnect($host,$p ort,15,'TITLE Test \nTEXT Text in
          >> popup\nPOPUP\n' );
          >>
          >> function socket_raw_conn ect ($server, $port, $timeout,$reque st) {
          >> if (!is_numeric($p ort) or !is_numeric($ti meout)) {return false;}
          >> $socket = fsockopen($serv er, $port, $errno, $errstr, $timeout);
          >> if(!$socket) { echo "Opening socket error"; exit(); }
          >>
          >> sleep(10); #Wait for program... bug :-)
          >> $put=fputs($soc ket, $request);
          >> sleep(10);
          >> fclose($socket) ;
          >> }
          >> ?>
          >>
          >> Now, I have tried the whole scala of \r \n \r\n \0x0a etc.. for \n but it
          >> doesn't seem to work..
          >>
          >> Anyone a bright idea???[/color]
          >
          > A firewall blocking the connection? What port are you using?
          >
          > BTW: I hope you're not writing an adware.
          >
          >[/color]


          Comment

          • Chung Leong

            #6
            Re: Send binary data to socket

            "Marco" <dont_send{spam }[mps]@this.address[webmind.nl].please.com> wrote in
            message news:41b8e09e$0 $45946$a344fe98 @news.wanadoo.n l...[color=blue]
            > Ok.. Seems the information was too little :-)
            >
            > here we go with a little more info:
            >
            > A friend of mine as programmed a simple popup kind of thing.
            > I made a scheduler in PHP, but to assure we don't forget any todo-items I
            > thought it would be a nice feature to let this scheduler (running on LINUX
            > server with apache/PHP) send messages to (in this case) my windows[/color]
            machine.[color=blue]
            > (e.g: call php page with aid of crontab)
            >
            > Now, this friend has a reputation with Delphi (pascal) and programmed a[/color]
            nice[color=blue]
            > little popup application.
            > To use it I have to connect to (if local) 127.0.0.1 port 12345 (with SSH /
            > putty raw connection) and after entering the Tilte of the popup, text and
            > the final POPUP command, I see a nice popup with the text I entered...
            >
            > ...
            > So the commands entered in the PUTTY window are quite simple:
            > TITLE Title of popup window
            > TEXT text in popup window
            > POPUP
            >
            > Now what I have to do (in php duh..) is sending these commands to the
            > client......... .....
            > So my thought would be creating a socket to the (windows) machine with[/color]
            the[color=blue]
            > popup-thing running and send the commands..
            > But it just doesn't seem to work..
            >
            > If anyone of you can help me out.. PLEASE!! :-)
            >
            > Thanx in advance,
            > Marco
            >
            >
            >
            >
            > "Quarco" <dontbother@hot mail.com> schreef in bericht
            > news:41b86bfc$0 $566$e4fe514c@n ews.xs4all.nl.. .[color=green]
            > > Hi,
            > >
            > > Quick & simple question:
            > > I have to send the next data to a socket in order to make a popup[/color][/color]
            visible[color=blue][color=green]
            > > on
            > > a windows machine..
            > >
            > > TITLE Title of popup [enter]
            > > TEXT Text in popup [enter]
            > > POPUP [enter]
            > >
            > >
            > > <?
            > > $s=socket_raw_c onnect($host,$p ort,15,'TITLE Test \nTEXT Text in
            > > popup\nPOPUP\n' );
            > >
            > > function socket_raw_conn ect ($server, $port, $timeout,$reque st) {
            > > if (!is_numeric($p ort) or !is_numeric($ti meout)) {return false;}
            > > $socket = fsockopen($serv er, $port, $errno, $errstr, $timeout);
            > > if(!$socket) { echo "Opening socket error"; exit(); }
            > >
            > > sleep(10); #Wait for program... bug :-)
            > > $put=fputs($soc ket, $request);
            > > sleep(10);
            > > fclose($socket) ;
            > > }
            > > ?>
            > >
            > > Now, I have tried the whole scala of \r \n \r\n \0x0a etc.. for \n but[/color][/color]
            it[color=blue][color=green]
            > > doesn't seem to work..
            > >
            > > Anyone a bright idea???
            > >
            > >
            > > Thanx in advance,
            > > Marco
            > >
            > >
            > >
            > >[/color][/color]

            For this kind of thing it makes much more sense for the client to poll the
            server across port 80. That way your program would still work when there's a
            firewall between the two.


            Comment

            • Marco

              #7
              Re: Send binary data to socket

              Funny, thought of that last night myself :-)

              Still, it was a nice learning-thing ..

              Thanx all for your time..

              Greetz,
              Marco



              "Chung Leong" <chernyshevsky@ hotmail.com> schreef in bericht
              news:h4ednZ7Y57 NW2yfcRVn-3Q@comcast.com. ..[color=blue]
              > "Marco" <dont_send{spam }[mps]@this.address[webmind.nl].please.com> wrote
              > in
              > message news:41b8e09e$0 $45946$a344fe98 @news.wanadoo.n l...[color=green]
              >> Ok.. Seems the information was too little :-)
              >>
              >> here we go with a little more info:
              >>
              >> A friend of mine as programmed a simple popup kind of thing.
              >> I made a scheduler in PHP, but to assure we don't forget any todo-items
              >> I
              >> thought it would be a nice feature to let this scheduler (running on
              >> LINUX
              >> server with apache/PHP) send messages to (in this case) my windows[/color]
              > machine.[color=green]
              >> (e.g: call php page with aid of crontab)
              >>
              >> Now, this friend has a reputation with Delphi (pascal) and programmed a[/color]
              > nice[color=green]
              >> little popup application.
              >> To use it I have to connect to (if local) 127.0.0.1 port 12345 (with SSH
              >> /
              >> putty raw connection) and after entering the Tilte of the popup, text and
              >> the final POPUP command, I see a nice popup with the text I entered...
              >>
              >> ...
              >> So the commands entered in the PUTTY window are quite simple:
              >> TITLE Title of popup window
              >> TEXT text in popup window
              >> POPUP
              >>
              >> Now what I have to do (in php duh..) is sending these commands to the
              >> client......... .....
              >> So my thought would be creating a socket to the (windows) machine with[/color]
              > the[color=green]
              >> popup-thing running and send the commands..
              >> But it just doesn't seem to work..
              >>
              >> If anyone of you can help me out.. PLEASE!! :-)
              >>
              >> Thanx in advance,
              >> Marco
              >>
              >>
              >>
              >>
              >> "Quarco" <dontbother@hot mail.com> schreef in bericht
              >> news:41b86bfc$0 $566$e4fe514c@n ews.xs4all.nl.. .[color=darkred]
              >> > Hi,
              >> >
              >> > Quick & simple question:
              >> > I have to send the next data to a socket in order to make a popup[/color][/color]
              > visible[color=green][color=darkred]
              >> > on
              >> > a windows machine..
              >> >
              >> > TITLE Title of popup [enter]
              >> > TEXT Text in popup [enter]
              >> > POPUP [enter]
              >> >
              >> >
              >> > <?
              >> > $s=socket_raw_c onnect($host,$p ort,15,'TITLE Test \nTEXT Text in
              >> > popup\nPOPUP\n' );
              >> >
              >> > function socket_raw_conn ect ($server, $port, $timeout,$reque st) {
              >> > if (!is_numeric($p ort) or !is_numeric($ti meout)) {return false;}
              >> > $socket = fsockopen($serv er, $port, $errno, $errstr, $timeout);
              >> > if(!$socket) { echo "Opening socket error"; exit(); }
              >> >
              >> > sleep(10); #Wait for program... bug :-)
              >> > $put=fputs($soc ket, $request);
              >> > sleep(10);
              >> > fclose($socket) ;
              >> > }
              >> > ?>
              >> >
              >> > Now, I have tried the whole scala of \r \n \r\n \0x0a etc.. for \n but[/color][/color]
              > it[color=green][color=darkred]
              >> > doesn't seem to work..
              >> >
              >> > Anyone a bright idea???
              >> >
              >> >
              >> > Thanx in advance,
              >> > Marco
              >> >
              >> >
              >> >
              >> >[/color][/color]
              >
              > For this kind of thing it makes much more sense for the client to poll the
              > server across port 80. That way your program would still work when there's
              > a
              > firewall between the two.
              >
              >[/color]


              Comment

              Working...