Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: wlan  (Read 9261 times)

0 Members and 1 Guest are viewing this topic.

dragonpiper

    Topic Starter


    Rookie

    Thanked: 1
    wlan
    « on: January 15, 2010, 11:27:19 PM »
    Hello computer hope chat members i wanted to know if someone could please help me edit this so it works  through the iternet rather than only locally. here is the  source.

    Thank you in advance  ;D



    {
      ***************************************************
      PSPdisp (c) 2008-2009 Jochen Schleu

      wlan.pas - functions dealing with wlan transfer

      This software is licensed under the BSD license.
      See license.txt for details.
      ***************************************************
    }

    unit wlan;

    interface

    uses
      SysUtils, Classes, ExtCtrls, Dialogs, WinSock;




    function WlanWaitForClient() : Boolean;
    function WlanShutdownServer() : Boolean;
    function WlanStartServer() : Boolean;
    function WlanCloseClient() : Boolean;
    function WlanSendBuffer(var Buffer: Array of Byte; DataSize: Integer): Boolean;
    function WlanReceiveData(var buffer; bufferSize: Integer): Boolean;
    function GETAllIPAddresses(): string;

    implementation

    uses
      Main;

    var
      SocketHandle : Integer;
      ClientHandle : Integer;
      SockAddr : TSockAddrIn;
      WSADataStruct : TWSAData;



    {
      WlanStartServer
      ---------------------------------------------------
      Initialize the server.
      ---------------------------------------------------
      Returns TRUE on success.
    }
    function WlanStartServer() : Boolean;
    var
      arg: Integer;
    begin
      Result := False;

      WSAStartup($101, WSADataStruct);

      // Create socket
      SocketHandle := Winsock.socket(PF_INET, SOCK_STREAM, 0);

      if (SocketHandle = INVALID_SOCKET) then
      begin
        MessageDlg('socket() failed!', mtError, [mbOK], -1);
        Exit;
      end;

      // Bind socket
      SockAddr.sin_family := AF_INET;
      SockAddr.sin_addr.S_addr := INADDR_ANY;
      SockAddr.sin_port := htons(17584);

      if (bind(SocketHandle, SockAddr, sizeof(SockAddr)) = SOCKET_ERROR) then
      begin
        MessageDlg('The port used by the PSPdisp server is in use. Probably another instance is already running.', mtError, [mbOK], -1);
        //MessageDlg('bind() failed!', mtError, [mbOK], -1);
        Exit;
      end;

      // Start listening, only accept 1 client (0 clients in backlog)
      if (listen(SocketHandle, 1) = SOCKET_ERROR) then
      begin
        MessageDlg('listen() failed!', mtError, [mbOK], -1);
        Exit;
      end;

      arg := 1000;
      setsockopt(SocketHandle, SOL_SOCKET, SO_RCVTIMEO, @arg, sizeof(arg));
      setsockopt(SocketHandle, SOL_SOCKET, SO_SNDTIMEO, @arg, sizeof(arg));

      Result := True;
    end;



    {
      GETAllIPAddresses
      ---------------------------------------------------
      Retrieves the IP addresses of all local network
      adapters.
      ---------------------------------------------------
      Returns a string containing the IP addresses.
    }
    function GETAllIPAddresses(): string;
    type
      TaPInAddr = array[0..10] of PInAddr;
      PaPInAddr = ^TaPInAddr;
    var
      phe: PHostEnt;
      pptr: PaPInAddr;
      Buffer: array[0..63] of Char;
      I: Integer;
      GInitData: TWSAData;
      tempString: string;
    begin
      Result := '';

      WSAStartup($101, GInitData);
      GetHostName(Buffer, SizeOf(Buffer));
      phe := GetHostByName(buffer);
      if phe = nil then Exit;
      pPtr := PaPInAddr(phe^.h_addr_list);
      I    := 0;
      while pPtr^ <> nil do
      begin
        tempString := inet_ntoa(pptr^^);
        if Result = '' then
          Result := tempString
        else
          Result := Result + ' or' + #10 + tempString;
        Inc(I);
      end;

      if (Result = '127.0.0.1') then
        Result := 'No local IP found. You may not be able to use the Wireless LAN mode.';
    end;





    {
      WlanShutdownServer
      ---------------------------------------------------
      Close the server handle.
      ---------------------------------------------------
      Returns TRUE.
    }
    function WlanShutdownServer() : Boolean;
    begin
      shutdown(SocketHandle, SD_BOTH);
      closesocket(SocketHandle);
      WSACleanup;
      Result := True;
    end;





    {
      WlanCloseClient
      ---------------------------------------------------
      Close a client handle.
      ---------------------------------------------------
      Returns TRUE.
    }
    function WlanCloseClient() : Boolean;
    begin
      shutdown(ClientHandle, SD_BOTH);
      closesocket(ClientHandle);
      Result := True;
    end;



    {
      WlanReceiveData
      ---------------------------------------------------
      Read data from the network.
      ---------------------------------------------------
      Returns TRUE on success.
    }
    function WlanReceiveData(var buffer; bufferSize: Integer): Boolean;
    var
      Bytessent: Integer;
      Retries: Integer;
    begin
      for Retries := 0 to 2 do
      begin
        Bytessent := recv(ClientHandle, buffer, bufferSize, 0);
        if (Bytessent <> SOCKET_ERROR) then
        begin
          Result := (Bytessent = bufferSize);
          Exit;
        end;
      end;
      Result := False;
    end;




    {
      WlanSendBuffer
      ---------------------------------------------------
      Send a buffer over Wlan.
      ---------------------------------------------------
      Returns TRUE on success.
    }
    function WlanSendBuffer(var Buffer: Array of Byte; DataSize: Integer): Boolean;
    var
      AmountSent: Integer;
      Position : Integer;
      BytesLeftToWrite: Integer;
      BytesToWrite: Integer;

    begin
      Position := 0;
      BytesToWrite := 0;

      while (Position < DataSize) do
      begin
        BytesLeftToWrite := DataSize - Position;
        if (BytesLeftToWrite > 0) then
        begin
          if BytesLeftToWrite > 2048 then
            BytesToWrite := 2048
          else
            BytesToWrite := BytesLeftToWrite;
        end;

        AmountSent := send(ClientHandle, Buffer[Position], BytesToWrite, 0);

        if (AmountSent = SOCKET_ERROR) then
        begin
          Result := False;
          Exit;
        end;

        Position := Position + AmountSent;
      end;

      Result := True;
    end;





    {
      WlanWaitForClient
      ---------------------------------------------------
      Wait for a client connection.
      ---------------------------------------------------
      Returns TRUE on successfull connection.
    }
    function WlanWaitForClient() : Boolean;
    var
      AddressLength : Integer;
      fds : Tfdset;
      timeout : timeval;
      arg: Integer;
    begin
      Result := False;

      while (MainForm.MenuEnabled.Checked) do
      begin
        AddressLength := sizeof(SockAddr);

        FD_ZERO(fds);
        FD_SET(SocketHandle, fds);
        timeout.tv_usec := 0;
        timeout.tv_sec := 2;

        if (select(SocketHandle + 1, @fds, nil, nil, @timeout) = SOCKET_ERROR) then
        begin
          MessageDlg('select() failed!', mtError, [mbOK], -1);
          Exit;
        end;

        if (FD_ISSET(SocketHandle, fds)) then
        begin
          ClientHandle := accept(SocketHandle, @SockAddr, @AddressLength);
          if (ClientHandle = SOCKET_ERROR) then
          begin
            MessageDlg('accept() failed!', mtError, [mbOK], -1);
            Exit;
          end;

          arg := 1000;
          setsockopt(SocketHandle, SOL_SOCKET, SO_RCVTIMEO, @arg, sizeof(arg));
          setsockopt(SocketHandle, SOL_SOCKET, SO_SNDTIMEO, @arg, sizeof(arg));

          Result := True;
          Break;
        end;
      end;
    end;


    end.
    « Last Edit: January 16, 2010, 07:43:25 PM by dragonpiper »

    mroilfield



      Mentor
    • Thanked: 42
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 11
    Re: wlan
    « Reply #1 on: January 16, 2010, 01:46:44 AM »
    i need someone to edit this so it works  throug hthe iternet rather than onlyy localy. here source
      ***************************************************
      PSPdisp (c) 2008-2009 Jochen Schleu

      wlan.pas - functions dealing with wlan transfer

      This software is licensed under the BSD license.
      See license.txt for details.
      ***************************************************

    How about you contact Jochen Schleu and see if they would edit it for you?
    You can't fix Stupid!!!

    Quantos



      Guru
    • Veni, Vidi, Vici
    • Thanked: 170
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Guru
    • OS: Linux variant
    Re: wlan
    « Reply #2 on: January 16, 2010, 01:53:51 AM »
    Why should we fix someone elses work?
    That just doesn't seem like a productive use of my time.
    Evil is an exact science.

    dragonpiper

      Topic Starter


      Rookie

      Thanked: 1
      Re: wlan
      « Reply #3 on: January 16, 2010, 02:41:17 AM »
      Quantos please stay out of my thread if your not here to help.  >:(

      mroilfield



        Mentor
      • Thanked: 42
        • Yes
        • Yes
      • Computer: Specs
      • Experience: Experienced
      • OS: Windows 11
      Re: wlan
      « Reply #4 on: January 16, 2010, 04:22:18 AM »
      Quantos please stay out of my thread if your not here to help.  >:(

      I think you need to read the forum rules. This is a licensed software that you are wanting us to change for you and that goes against the rules.
      You can't fix Stupid!!!

      Mulreay

      • Guest
      Re: wlan
      « Reply #5 on: January 16, 2010, 08:34:33 AM »
      i need someone to edit this so it works  throug hthe iternet rather than onlyy localy. here source

      And just on another note. If you do need help with something you may want to rephrase your request. We are all volunteers here last time I checked and a please and thankyou go a long way.

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: wlan
      « Reply #6 on: January 16, 2010, 09:05:04 AM »
      1. You haven't told us what language it is. Of course I know it's either Delphi or Pascal for Windows, but it would be nice to know things such as what version it is.

      "PSPdisp v0.1: use your PSP as an extra PC monitor"

      Why would you want to do this over the internet?

      Either way, just make GETAllIPAddresses() return a single IP equivalent to your target machine on the net; should work then.
      I was trying to dereference Null Pointers before it was cool.

      Salmon Trout

      • Guest
      Re: wlan
      « Reply #7 on: January 16, 2010, 11:19:11 AM »
      Quantos please stay out of my thread if your not here to help.  >:(

      You do not "own" this thread, and making posts like the one I have quoted here is a really good way of getting no help at all!  :)
      « Last Edit: January 16, 2010, 02:27:09 PM by Salmon Trout »

      Salmon Trout

      • Guest
      Re: wlan
      « Reply #8 on: January 16, 2010, 11:22:05 AM »
      I have looked at every single one of dragonpiper's 5 posts, and I can't see a single one that anyone would thank him for.

      Salmon Trout

      • Guest
      Re: wlan
      « Reply #9 on: January 16, 2010, 12:15:08 PM »
      1. You haven't told us what language it is. Of course I know it's either Delphi or Pascal for Windows, but it would be nice to know things such as what version it is.

      Quote
      The display driver needs the Microsoft WDK (Windows Driver Kit).

      Building the Windows application requires Borland Turbo Delphi.

      The PSPSDK (PSP toolchain) is needed for compiling the Playstation
      Portable application.

      http://dl.qj.net/psp/homebrew-applications/pspdisp-v01-pc.html

      dragonpiper

        Topic Starter


        Rookie

        Thanked: 1
        Re: wlan
        « Reply #10 on: January 16, 2010, 07:30:01 PM »
        1. You haven't told us what language it is. Of course I know it's either Delphi or Pascal for Windows, but it would be nice to know things such as what version it is.

        "PSPdisp v0.1: use your PSP as an extra PC monitor"

        Why would you want to do this over the internet?

        Either way, just make GETAllIPAddresses() return a single IP equivalent to your target machine on the net; should work then.


        THANK SO MUCH = ) i'm gonna try that now  ;D btw 0.1 is a old version the one i'm using is 0.4.

        Also the reason i want this top be possible is so i can control my computer anywhere using my psp.

        dragonpiper

          Topic Starter


          Rookie

          Thanked: 1
          Re: wlan
          « Reply #11 on: January 16, 2010, 07:33:22 PM »
          I think you need to read the forum rules. This is a licensed software that you are wanting us to change for you and that goes against the rules.

          The developer gave permission to edit the program. 8)

          Quantos



            Guru
          • Veni, Vidi, Vici
          • Thanked: 170
            • Yes
            • Yes
          • Computer: Specs
          • Experience: Guru
          • OS: Linux variant
          Re: wlan
          « Reply #12 on: January 16, 2010, 07:33:45 PM »
          Quantos please stay out of my thread if your not here to help.  >:(

          Some people just deserve a really good kick in the arse.  You are one of them.
          Evil is an exact science.

          dragonpiper

            Topic Starter


            Rookie

            Thanked: 1
            Re: wlan
            « Reply #13 on: January 16, 2010, 07:39:54 PM »
            The reason i posted that message is because you kept acting like a idiot in live chat. Anyway thank you everyone who is helping i appreciate it. ;D

            Quantos



              Guru
            • Veni, Vidi, Vici
            • Thanked: 170
              • Yes
              • Yes
            • Computer: Specs
            • Experience: Guru
            • OS: Linux variant
            Re: wlan
            « Reply #14 on: January 16, 2010, 07:54:06 PM »
            The reason i posted that message is because you kept acting like a idiot in live chat. Anyway thank you everyone who is helping i appreciate it. ;D

            I don't think telling you that you needed to contact your ISP and that if the program won't do what you want that you may need to find a new one that will is acting like an idiot.  Get over it and grow up.
            Evil is an exact science.

            mroilfield



              Mentor
            • Thanked: 42
              • Yes
              • Yes
            • Computer: Specs
            • Experience: Experienced
            • OS: Windows 11
            Re: wlan
            « Reply #15 on: January 17, 2010, 12:03:16 AM »
            The developer gave permission to edit the program. 8)

            Yeah why don't you prove that.

            If you got permission to edit the program why not just ask the developer to edit it for you?
            You can't fix Stupid!!!

            dragonpiper

              Topic Starter


              Rookie

              Thanked: 1
              Re: wlan
              « Reply #16 on: January 17, 2010, 12:18:35 AM »
              because if i was to ask him he would probably just add to a later version which would take months. Also if is wasn't able to edit it why would he distribute the source with every release of the program and include comments in the coding ?

              Quantos



                Guru
              • Veni, Vidi, Vici
              • Thanked: 170
                • Yes
                • Yes
              • Computer: Specs
              • Experience: Guru
              • OS: Linux variant
              Re: wlan
              « Reply #17 on: January 17, 2010, 12:34:51 AM »
              This program isn't FOSS(Free Open Source Software), it's illegal for us to modify it.  You will have to live with it the way it is, or find another program that does what you want.
              Evil is an exact science.

              mroilfield



                Mentor
              • Thanked: 42
                • Yes
                • Yes
              • Computer: Specs
              • Experience: Experienced
              • OS: Windows 11
              Re: wlan
              « Reply #18 on: January 17, 2010, 12:54:52 AM »
              because if i was to ask him he would probably just add to a later version which would take months. Also if is wasn't able to edit it why would he distribute the source with every release of the program and include comments in the coding ?

              you still haven't proven that the developer gave you permission to edit or have some one else edit his software.
              You can't fix Stupid!!!

              Zorro

              • Guest
              Re: wlan
              « Reply #19 on: January 17, 2010, 01:35:44 AM »
              If you're the police where are your badges?

              Salmon Trout

              • Guest
              Re: wlan
              « Reply #20 on: January 17, 2010, 03:30:45 AM »
              Quote from: Quantos
              This program isn't FOSS(Free Open Source Software), it's illegal for us to modify it.

              Yes it is! Polish your eyeglasses! If it was pirated Microsoft source code, that "illegal" might have some meaning, (maybe) but see below...

              Quote from: mroilfield
              you still haven't proven that the developer gave you permission to edit or have some one else edit his software.

              He did, actually, in his first post. (Am I the only person here who can read?)  ::)

              ...here is the  source.

              {
                ***************************************************
                PSPdisp (c) 2008-2009 Jochen Schleu

                wlan.pas - functions dealing with wlan transfer


                This software is licensed under the BSD license.
                See license.txt for details.
                ***************************************************
              }



              Come on guys! I know that this is a technical forum, not a legal one, but come on! I have heard some BS in my time, but some of that above takes the biscuit! How hard is it to check out what the BSD Licence is, and what it means?

              There is this search site called "Guggle" or something like that, and it has this one very handy feature. If you type in some words like "BSD License" it finds pages with those words on! Real, neat, eh? In fact it found me a site which says this...

              Quote
              BSD License Explained In Layman Terms

              It’s always bothered me, how confusing the many Free and Open Source Licenses are. There are many to choose from. As a developer, which one do you pick? How do you choose what software to run? What applications or services will you deploy pending licensing? These are big questions, and I hope to make explaining licenses easy and in simple terms for the average user. I’ll start with one of the more common licenses, the BSD license.

              In a nutshell, the BSD license is a very open license, allowing you do do practically anything with the software. It’s less restrictive than the GPL, but more restrictive than the Public Domain. There are only a couple precepts that must be adhered to, when using this license:

                  * You are free to redistribute the software, in binary or source form, as long as the copyright, conditions and disclaimer are present.
                  * You cannot use the name of the originating organization, or contributers, to promote derivatives of the software, without written consent.

              If adhered to, you are free to modify, copy and redistribute BSD-licensed software in either source or binary form as you see fit. You are not required to return code or patches to the upstream BSD-licensed software. You are free to change the license, or charge for derivatives, of the software, be it commercial or proprietary.

              BSD-licensed software is particularly attractive to organizations providing a service, such as GMail, or embedded applications, such as your mobile phone or stereo. The company/developer can use BSD-licensed software to produce binary applications or services, without releasing the source code.


              http://pthree.org/2007/08/08/bsd-license-explained-in-layman-terms/

              So, in short, the BSD licence is less restrictive than other FOSS licences such as e.g. GPL, which forces you to release the source code. You can do whatever you like in the way of altering the source code and recompiling, you can then sell or give away the altered product, (binaries and/or source as you wish) and as long as you stick to those 2 bullet points above, you'll be fine.





              « Last Edit: January 18, 2010, 06:58:32 AM by Salmon Trout »

              dragonpiper

                Topic Starter


                Rookie

                Thanked: 1
                Re: wlan
                « Reply #21 on: January 17, 2010, 03:45:07 AM »
                Finally someone who understand licensing. Thank you for clearing that up.  ;D

                Salmon Trout

                • Guest
                Re: wlan
                « Reply #22 on: January 17, 2010, 03:48:55 AM »
                Finally someone who understand licensing. Thank you for clearing that up.  ;D

                I know I said some hard things to you, but you did not deserve all that crap about licencing, when you put the licence details in plain view in your first post.

                Quantos



                  Guru
                • Veni, Vidi, Vici
                • Thanked: 170
                  • Yes
                  • Yes
                • Computer: Specs
                • Experience: Guru
                • OS: Linux variant
                Re: wlan
                « Reply #23 on: January 18, 2010, 05:54:03 AM »
                Hey, look at that, it is there.

                I don't know how I missed it, oh well.

                My apologies Dragonpiper.
                Evil is an exact science.

                dragonpiper

                  Topic Starter


                  Rookie

                  Thanked: 1
                  Re: wlan
                  « Reply #24 on: January 21, 2010, 12:35:31 PM »
                  thanks for your apologies. :)

                  dragonpiper

                    Topic Starter


                    Rookie

                    Thanked: 1
                    Re: wlan
                    « Reply #25 on: January 24, 2010, 10:37:00 PM »
                    Will someone please help me.

                    Salmon Trout

                    • Guest
                    Re: wlan
                    « Reply #26 on: January 25, 2010, 12:19:42 AM »
                    I think we'd have to teach you Pascal in order to effectively help you. You're at the wrong forum, matey.