Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Can I communicate directly with your computer?

Hi,

Is there a program written that I can use that will allow both users to send files to each other  via the internet without a client/server relationship as in skipping the middle man at the FTP site or HTTP site? Elaborating a bit, say we both sign on at the same time and agree to transfer files back and forth via this  program. Or saying it still another way, I do not need a complicated FTP server/client to do this, just the ability to send the file, and display stats for it.
I am not aware that one exists  but then  I haven't seen that  much.

Delphi3
0
delphi3
Asked:
delphi3
  • 10
  • 8
  • 2
1 Solution
 
ptmcompCommented:
Yes, there is ICQ.
0
 
delphi3Author Commented:
Ptmcomp,
Can you explain further? Is it a for sale item, downloadable or  delpi programmable?
I am not familiar with the designation.

Delphi3
0
 
delphi3Author Commented:
Ptmcomp,

I went out on the net and came up with
http://www.mirabilis.com/suites/newuser.html

Is this what you were referring to? or is there another place?

Delphi3
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ptmcompCommented:
Excatly, that's it.
0
 
God_AresCommented:
I know how to do this in delphi without using icq..
want it?
0
 
delphi3Author Commented:
God_Ares.

Sure

Delphi3
0
 
delphi3Author Commented:
God_Ares,
I guess that 'Sure' could be misunderstood.
Yes I would like to see the program

Delphi3
0
 
God_AresCommented:
here is some code
i'm making a kind of chatter that can also transfer files (d5)... that will be done proberly monday...

if you want the program just say so..

here some code.. use a any tcp/ip component...

Server part:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ScktComp, ExtCtrls, StdCtrls;

Const
  //You may set this to False if you would like the whole image!
  STRETCH = True;
  STRETCH_WIDTH = 200;
  STRETCH_HEIGHT = 150;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    ServerSocket1: TServerSocket;
    procedure ServerSocket1ClientRead(Sender: TObject;
      Socket: TCustomWinSocket);
  private
    { Private declarations }
    Stream: TMemoryStream;
    procedure SendNextPart(Socket: TCustomWinSocket);
  public
    { Public declarations }
    Timer: TTimer;
    procedure OnTime(Sender: TObject);
    procedure SendScreen(Socket: TCustomWinSocket);
  protected
    Bitmap: TBitmap;
  end;

var
  Form1: TForm1;


implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Bitmap:= TBitmap.Create;
  if STRETCH then
  begin
    Bitmap.Width:= STRETCH_WIDTH;
    Bitmap.height:= STRETCH_HEIGHT;
  End else
  begin
    Bitmap.Width:= Screen.Width;
    Bitmap.Height:= Screen.Height;
  End;
  Timer:= TTimer.Create(Self);
  Timer.Interval:= 1000;
  Timer.OnTimer:= OnTime;
  Timer.Enabled:= True;
  ServerSocket1:= TServerSocket.Create(Self);
  With ServerSocket1 do
  begin
    Port:= 2500;
    Active:= True;
    ServerType:= stNonBlocking;
    OnClientRead:= ServerSocket1ClientRead;
  End;
  Stream:= TMemoryStream.Create;
end;

procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
var
  S: String;
Begin
  S:= Socket.ReceiveText;
  If S='Get me the screen' then SendScreen(Socket) else
  If S='Send next' then SendNextPart(Socket) else
  If S='Done' then Socket.Close;
End;

procedure TForm1.SendScreen(Socket: TCustomWinSocket);
var
  Size: Integer;
Begin
  Bitmap.SaveToStream(Stream);
  Size:= Stream.Size;
  Stream.Position:= 0;
  Socket.SendBuf(Size,SizeOf(Size));
End;

procedure TForm1.SendNextPart(Socket: TCustomWinSocket);
const
  MaxChunkSize = 8192; { copy in 8K chunks }
var
  ChunkSize: Integer;
  CopyBuffer: Array[0..MaxChunkSize] of Byte;
Begin
  Chunksize:= Stream.Size-Stream.Position;
  If ChunkSize>0 then
  begin
    If ChunkSize > MaxChunkSize then ChunkSize:= MaxChunkSize;
    Stream.Read(CopyBuffer,ChunkSize);
    Socket.SendBuf(CopyBuffer,ChunkSize);
  End else
    Stream.Clear; //The final
End;

procedure TForm1.OnTime(Sender: TObject);
var
  dwRop: DWord;
  DC: hDC;
begin
  dwRop:= SRCCOPY;
  DC:= GetDC(0);
  If STRETCH then
    StretchBlt(
      Bitmap.Canvas.Handle, // handle to destination device context
      0, // x-coordinate of destination rectangle's upper-left corner
      0, // y-coordinate of destination rectangle's upper-left corner
      Bitmap.Width, // width of destination rectangle
      Bitmap.Height, // height of destination rectangle
      DC, // handle to source device context
      0, // x-coordinate of source rectangle's upper-left corner
      0, // y-coordinate of source rectangle's upper-left corner
      Screen.Width, // width of source rectangle
      Screen.Height, // height of source rectangle
      dwRop        // raster operation code (See below)
    )
  else
    BitBlt(
      Bitmap.Canvas.Handle, // handle to destination device context
      0, // x-coordinate of destination rectangle's upper-left corner
      0, // y-coordinate of destination rectangle's upper-left corner
      Bitmap.Width, // width of destination rectangle
      Bitmap.Height, // height of destination rectangle
      DC, // handle to source device context
      0, // x-coordinate of source rectangle's upper-left corner
      0, // y-coordinate of source rectangle's upper-left corner
      dwRop        // raster operation code (See below)
    );
  ReleaseDC(0,DC)
{
BLACKNESS Fills the destination rectangle using the color associated with
index 0 in the physical palette. (This color is black for the
                default physical palette.)
DSTINVERT Inverts the destination rectangle.
MERGECOPY Merges the colors of the source rectangle with the specified
pattern by using the Boolean AND operator.
MERGEPAINT Merges the colors of the inverted source rectangle with the
colors of the destination rectangle by using the Boolean OR
                operator.
NOTSRCCOPY Copies the inverted source rectangle to the destination.
NOTSRCERASE Combines the colors of the source and destination rectangles
by using the Boolean OR operator and then inverts the resultant
                color.
PATCOPY Copies the specified pattern into the destination bitmap.
PATINVERT Combines the colors of the specified pattern with the colors of
the destination rectangle by using the Boolean XOR operator.
PATPAINT Combines the colors of the pattern with the colors of the
inverted source rectangle by using the Boolean OR operator. The
                result of this operation is combined with the colors of the
                destination rectangle by using the Boolean OR operator.
SRCAND Combines the colors of the source and destination rectangles
by using the Boolean AND operator.
SRCCOPY Copies the source rectangle directly to the destination
rectangle.
SRCERASE Combines the inverted colors of the destination rectangle with
the colors of the source rectangle by using the Boolean AND operator.
SRCINVERT Combines the colors of the source and destination rectangles
by using the Boolean XOR operator.
SRCPAINT Combines the colors of the source and destination rectangles by
using the Boolean OR operator.
WHITENESS Fills the destination rectangle using the color associated with
index 1 in the physical palette. (This color is white for the
                default physical palette.)
}
End;

end.






ClientPart:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ScktComp, StdCtrls, ExtCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    ProgressBar: TProgressBar;
    Button1: TButton;
    Button2: TButton;
    ClientSocket1: TClientSocket;
    Image1: TImage;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure ClientSocket1Connect(Sender: TObject;
      Socket: TCustomWinSocket);
    procedure ClientSocket1Error(Sender: TObject; Socket: TCustomWinSocket;
      ErrorEvent: TErrorEvent; var ErrorCode: Integer);
    procedure Button2Click(Sender: TObject);
    procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
    procedure ClientSocket1Disconnect(Sender: TObject;
      Socket: TCustomWinSocket);

  private
    Stream: TMemoryStream;
  public
    Procedure UpdateProgressBar;
  protected
    Bitmap: TBitmap;
    Receiving: Boolean;
    FSize: Integer;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption:= 'Connecting..';
  ClientSocket1.Open;
end;

procedure TForm1.ClientSocket1Connect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
  Label1.Caption:= 'Connected';
  Receiving:= False;
  FSize:= 0;
end;

procedure TForm1.ClientSocket1Error(Sender: TObject;
  Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
  var ErrorCode: Integer);
begin
  ShowMessage('Did you startup the server? I cannot find it!');
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
  if ClientSocket1.Active then
    ClientSocket1.Socket.SendText('Get me the screen');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Label1:= TLabel.Create(Self);
  Label1.SetBounds(32,72,32,13);
  Label1.Parent:= Self;
  Label1.Caption:= 'Idle..';
  Button1:= TButton.Create(Self);
  Button1.SetBounds(8,8,75,25);
  Button1.Parent:= Self;
  Button1.Caption:= 'Connect';
  Button1.OnClick:= Button1Click;
  Button2:= TButton.Create(Self);
  Button2.SetBounds(8,40,75,25);
  Button2.Parent:= Self;
  Button2.Caption:= 'Get screen';
  Button2.OnClick:= Button2Click;
  ClientSocket1:= TClientSocket.Create(Self);
  With ClientSocket1 do
  begin
    Active := False;
    ClientType := ctNonBlocking;
    Port := 2500;
    Address := '127.0.0.1';
    OnConnect := ClientSocket1Connect;
    OnDisconnect := ClientSocket1Disconnect;
    OnRead := ClientSocket1Read;
    OnError := ClientSocket1Error;
  end;
  Image1:= TImage.Create(Self);
  Image1.SetBounds(100,0,0,0);
  Image1.AutoSize:= true;
  Image1.Parent:= Self;

  Stream:= TMemoryStream.Create;
  ProgressBar:= TProgressBar.Create(Self);
  ProgressBar.Min:= 0;
  ProgressBar.Align:= alBottom;
  ProgressBar.Parent:= Self;
end;

Procedure TForm1.UpdateprogressBar;
Begin
  ProgressBar.Position:= ProgressBar.Max-FSize;
  progressBar.Update;
End;

procedure TForm1.ClientSocket1Read(Sender: TObject;
  Socket: TCustomWinSocket);
const
  MaxChunkSize = 8192; { copy in 8K chunks }
var
  BytesReceived: Longint;
  CopyBuffer: Array[0..MaxChunkSize] of Byte; { buffer for copying }
  ChunkSize: Integer;
  TempSize: Integer;
begin
  If FSize=0 then
  begin
    If Socket.ReceiveLength>=SizeOf(TempSize) then
    begin
      Socket.ReceiveBuf(TempSize,SizeOf(TempSize)); //get the size
      Stream.SetSize(TempSize);
      Stream.Position:= 0;
      ProgressBar.Max:= TempSize;
      FSize:= TempSize; //Threadsafe code!
    End;
  End;
  If (FSize>0) and not(Receiving) then
  begin
    Receiving:= True;
    While Socket.ReceiveLength>0 do
    Begin
      ChunkSize:= Socket.ReceiveLength;
      If ChunkSize > MaxChunkSize then ChunkSize:= MaxChunkSize;
      BytesReceived:= Socket.ReceiveBuf(CopyBuffer,ChunkSize);
      Stream.Write(CopyBuffer, BytesReceived); { ...write chunk }
      Dec(FSize,BytesReceived);
      UpdateProgressBar;
    End;
    //This is called "to Syncronize trasnsmissions"
    Socket.SendText('Send next');
    If FSize=0 then
    begin
      Socket.SendText('Done');
      Stream.Position:= 0;
      Image1.Picture.Bitmap.LoadFromStream(Stream);
      FSize:= 0;
      ProgressBar.Position:= 0;
//      Stream.SetSize(0);
      Stream.Clear;
    End;
    Receiving:= False;
  End;
end;


procedure TForm1.ClientSocket1Disconnect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
  Label1.Caption:= 'Disconnected';
end;

end.


there is a way to transfer files in d5 verry easy... want that too??  

btw ypu got d1,d2,d3,d4,d5 ??

Greetz

God_Ares

0
 
God_AresCommented:
the source is for sending a screen but it can be adjusted for files 2
0
 
delphi3Author Commented:
God_Ares,
First you need/wanted to know that I have  the D4 version and I also have the Standard Edition.
I have separated the client and server parts of your answer into separate programs, and tried to test the programs. That means that after I  logged on the Internet and  started to run your program  it gave  me an error message that my  'Application  not licensed to use the feature.' There also seems to be parts that are not there.  For instance during the run the  scktcomp.pas was needed.
Can I download from you the entire package/program  from your FTP site or HTTP site? that to include the files that make it run?

Delphi3
0
 
God_AresCommented:
So you have d4.. damm i have d5(standard), but no problem i'll uninstall d5 and install d4

but i'm not @home right now so you have to wait until monday (no delphi @work :( )

i'll make a nice program that runs in d5 and one that runs in d4.. K?

You can check www.torry.ru for nice tcp/ip components.

i'm sorry you have to wait until monday..
0
 
delphi3Author Commented:
God_Ares,
No problem, Monday is fine. Thanks for letting me know when. And I'll check at www.tory.ru  between now and then.

Delphi3
0
 
God_AresCommented:
ok you asked 4 it and i wrote it

it can easaly be manipulated to ask for confirmation etc...


i'm using standard components (d4) should work in d5 2.. did't test it do...

well here is the link..
it is called filetransver.zip

http://www.angelfire.com/ok/GODARES/downl.html

(btw  I've installed d4 pro)


i guezz i deserve the points..
0
 
delphi3Author Commented:
God_Ares,
Your gift of a filetransver.zip file is most welcome. Yet as I study it and prepared to run it  there are a few units that are not included in  the zip. In the uses it  needs/wants   NMStrm,Psock, ScktComp. I believe that these are  the only  'extra units' that are needed to make it work. Do you have them to include?

Delphi3
0
 
God_AresCommented:
hmmm that's strange it should be included with d4 pro, at least i'v got them...

just give me an e-mail adres and i'll send them over. (after work that is, still no dx :(   )

Greetz

....
0
 
delphi3Author Commented:
God_Ares,
As noted in the 18 April message from me, I have the D4 standard version, not the D4 pro version that you have. That is why I do not have those units.

I do not want to publish my email address here. And you have no legal right to share those units with me by the terms of you agreement with delphi/borland/inprise.   Sorry.

I will call the matter settled, pay you the 50 points for your effort, and call it a good job done.

I am tired of it all.

Delphi3
0
 
God_AresCommented:
ok, thanx you for the points, i hope you will get d4 pro from your boss soon.

Greetz

God_Ares
0
 
delphi3Author Commented:
God_Ares,
As for a boss, there is no one but myself. The production of the work  are at my own pace, and the pay is whatever, usually zero. As for soon, probably never.

Delphi3

0
 
God_AresCommented:
than buy d5 and substract it from the taxbill...

Are you a student student or are you someone learning delphi?
0
 
delphi3Author Commented:
God_Ares,
Click on my From:Delphi3 above and it will give you my history.

As for buying D5, Standard Edition, I thought about it but have not had  the motivation to spend the funds. Delphi is neat, lots of easy buttons/ etc but is not the greatest when it is combined with/married to win98. But then I have not seen it all to know what is the better to buy.

Delphi3  
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 10
  • 8
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now