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

Author Topic: wlan  (Read 10231 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.