[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Accessing Winsock with Delphi 2.0

Posted on 1997-03-18
3
Medium Priority
?
387 Views
Last Modified: 2010-04-04
How do I use Winsock with Delphi 2.0 to initiate FTP protocols for uploading and downloading files to an FTP server using a dial-up connection.  I also need to know how I use Winsock to login into a POP server for an email program and HTTP programs.  I need the general info to get me started, so if you need more specific info, let me know.
0
Comment
Question by:peteyj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
mheacock earned 200 total points
ID: 1334894
Using Winsock at the API level is reasonably complex...there are synchronization details you have to beware of, buffering, etc.

I don't mean to be rude, but it sound as if you do not know that much about Winsock, or are at least new to it.  I'd suggest going to the Delphi Super Page and picking up a Winsock component (there are a lot there)...you'll find them easier to use as they will handle all the nitty-gritty details for you and you can concentrate on the higher level stuff you probably want to perform.

The URL of Delphi Super Page is:

   http://www.cdrom.com/pub/delphi_www/

Feel free to comment.  I don't mean to steer you towards the easier route, but if you are new to Winsock, like I suspect, you'll save yourself much aggrevation and headache buy checking out the freeware/shareware winsock components available.

I've done a bit of Winsock programming at the API level.  I don't anymore.  What's the point.  Enough people have already invented the wheel, why try and reinvent it.  I say, if someone else has done it well and they are offering it to you, then use it.  Don't fall into the trap of thinking you have to know everything at the lower-levels...you don't...and if you do try, you'll find yourself falling further and further behind the technology...thigns are moving to fast today to be able to understand everything.

Oops...sorry for the lecture.

The point is this...if you want code to perform what you are asking at the low-level, then you probably won't get it here.  Winsock is complex and the code you require would be fairly lengthy.  So, check out some shareware/freeware.

Redundantly yours,
0
 

Expert Comment

by:mlanza
ID: 1334895
Those who are interested in programming the WinSock API from Delphi would find the book "Delphi 2 Developers Solutions" very useful.  It takes you through creating FTP, SMTP & POP projects.  Full source code on CD.

Publisher:  Waite Group Press
ISBN:  1-57169-071-9
0
 

Expert Comment

by:peteraa
ID: 2918440
How do I use Winsock with Delphi 2.0 to initiate FTP protocols for uploading and downloading files to an FTP server using a dial-up connection.  I also need to know how I use Winsock to login into a POP server for an email program and HTTP programs.  I need the general info to get me started, so if you need more specific info, let me know.

For FTP and HTTP I use Wininet. It works well and its a lot easier...
Heres an an example

Program project1;

uses
Windows, Wininet, Sysutils;

{$R *.res}

var
ISession, Connection, HTTPReq: HINTERNET;
retstr:string;
Data: Array[0..$400] of Char;
BytesToRead: DWord;

begin
ISession:=InternetOpen(PChar('UserAgent'), LOCAL_INTERNET_ACCESS, nil, INTERNET_SERVICE_HTTP, 0);

Connection:=InternetConnect(Session, PChar('www.yourserver.com,'), 80, Pchar(''), Pchar(''), INTERNET_SERVICE_HTTP, 0, 0);

HTTPReq:=HttpOpenRequest(Connection, PChar('GET'), PChar('directory/filename.ext'), PChar('HTTP/1.1'), Pchar('Refferer'),PChar('text/html, image/gif, */*, etc'),    $8000000, 0);

HttpSendRequest(HTTPReq, '', 0, nil,0);

while True do
               begin
               if not InternetReadFile(HTTPReq, @Data, Dword(SizeOf(Data)),BytesToRead) then
               begin
               messageBox(0, 'An error occured while accessing the Server', Pchar('Peters emu'), MB_OK);
               break;
               end
               else
               if BytesToRead = 0 then break
               else
               retstr:= retstr+ Data;
               end;

               internetclosehandle(HTTPReq);
              internetclosehandle(ISession);
              internetclosehandle(Connection);
end.
0

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

649 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