Solved

Can I  communicate directly with your computer?

Posted on 2000-04-14
20
150 Views
Last Modified: 2010-04-04
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
Comment
Question by:delphi3
  • 10
  • 8
  • 2
20 Comments
 
LVL 10

Expert Comment

by:ptmcomp
Comment Utility
Yes, there is ICQ.
0
 
LVL 4

Author Comment

by:delphi3
Comment Utility
Ptmcomp,
Can you explain further? Is it a for sale item, downloadable or  delpi programmable?
I am not familiar with the designation.

Delphi3
0
 
LVL 4

Author Comment

by:delphi3
Comment Utility
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
 
LVL 10

Expert Comment

by:ptmcomp
Comment Utility
Excatly, that's it.
0
 
LVL 7

Expert Comment

by:God_Ares
Comment Utility
I know how to do this in delphi without using icq..
want it?
0
 
LVL 4

Author Comment

by:delphi3
Comment Utility
God_Ares.

Sure

Delphi3
0
 
LVL 4

Author Comment

by:delphi3
Comment Utility
God_Ares,
I guess that 'Sure' could be misunderstood.
Yes I would like to see the program

Delphi3
0
 
LVL 7

Expert Comment

by:God_Ares
Comment Utility
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
 
LVL 7

Expert Comment

by:God_Ares
Comment Utility
the source is for sending a screen but it can be adjusted for files 2
0
 
LVL 4

Author Comment

by:delphi3
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 7

Expert Comment

by:God_Ares
Comment Utility
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
 
LVL 4

Author Comment

by:delphi3
Comment Utility
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
 
LVL 7

Accepted Solution

by:
God_Ares earned 50 total points
Comment Utility
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
 
LVL 4

Author Comment

by:delphi3
Comment Utility
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
 
LVL 7

Expert Comment

by:God_Ares
Comment Utility
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
 
LVL 4

Author Comment

by:delphi3
Comment Utility
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
 
LVL 7

Expert Comment

by:God_Ares
Comment Utility
ok, thanx you for the points, i hope you will get d4 pro from your boss soon.

Greetz

God_Ares
0
 
LVL 4

Author Comment

by:delphi3
Comment Utility
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
 
LVL 7

Expert Comment

by:God_Ares
Comment Utility
than buy d5 and substract it from the taxbill...

Are you a student student or are you someone learning delphi?
0
 
LVL 4

Author Comment

by:delphi3
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now