?
Solved

Accessing Winsock with Delphi 2.0

Posted on 1997-03-18
3
Medium Priority
?
382 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

770 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