Link to home
Start Free TrialLog in
Avatar of Haxiom
Haxiom

asked on

VB Winsock

I'm new to VB. I'd like to know how to simply login to a server with a username, and password. Any protocols would be of help.
Thx


I'm specifically refering to logging in to Yahoo! and
Keeping the connection open.
Sorry my original question was so vague.
Avatar of vinnyd79
vinnyd79

what type of server do you want to login to?
Yea you need to know what server you want to get into.  Almost all Servers have diffrent ways to login. If you give us a little idea of what you are wanting to do then we could point you in the right direction.  If you are just wanting to learn the basics of server communication then there are real world examples that we could give Like:

Writing a simple program that lets you hit a daytime server.

Or Sending a e-mail through a smpt server

What do you want to do?  If you are just wanting to learn about servers the best way is to play with telnet
For FTP and HTTP, simply use the InternetOpen function of wininet.dll, then you can use all ftp and http functions you want

If it's just FTP you're after, please let me know, since I just finished developing an ocx that will allow you to open as much simultanious connections you like, and use the functions:

FTP_CD, FTP_RMDIR, FTP_MKDIR, FTP_GET, FTP_PUT, FTP_RENAME, FTP_DIR, and any other ftp function you would need.

If you want to program them yourself, visit the MSDN site and type "wininet.dll" in the search box.  You will then get a complete list of all functions suported by wininet.dll (both FTP, HTTP and GOPHER)

The function descriptions are ment for C programmers, but are easy converted to vb format

Example from MSDN Site for function FTPGetFile

Syntax

BOOL FtpGetFile(
    HINTERNET hConnect,
    LPCTSTR lpszRemoteFile,
    LPCTSTR lpszNewFile,
    BOOL fFailIfExists,
    DWORD dwFlagsAndAttributes,
    DWORD dwFlags,
    DWORD_PTR dwContext
);

Parameters

hConnect
 [in] description
lpszRemoteFile
 [in] descr...
lpszNewFile
 [in] descr...
fFailIfExists
 [in] descr...
dwFlagsAndAttributes
 [in] descr...
dwFlags
 [in] descr
dwContext
 [in] descr...

In VB, this translates to:

Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hConnect As Long, ByVal remotefilename As String, ByVal localfilename As String, ByVal failifexists As Boolean, ByVal flagsandattributes As Long, ByVal dwflags As Long, ByVal context As Long) As Boolean


Variable type conversion:

Not all C types are available in Visual Basic, just use the following equivalents:

    HINTERNET --> LONG
    LPCTSTR --> STRING
    LPCTSTR --> STRING
    BOOL --> BOOLEAN
    DWORD --> LONG
    DWORD --> LONG
    DWORD_PTR --> LONG

Determine if you pass by value or by reference:

dwContext
 [in] descr...

This parameter is passed by value, the [in] C directive states just that

somevar
  [out] descr...
  [in, out] descr...

This paremeter is passed by reference.  This is the case in both [out] and [in, out] examples.

Furthermore, an * in a C type means 'a pointer to', so pass that variable by reference to, regardless of the [in] directive in the C description

For those interested, just send me a msg and I'll be more than happy to send you a typelib that you can use in VB with All FTP functions you need.  Or, if you wish, an home-made ocx for plug and ftp functionality

With kind regards

Ramses
Avatar of Éric Moreau
Go to this website and download the FREE SocketWrench control (http://www.catalyst.com/cgi-bin/download.cgi?product=wrench)

SocketWrench is a superb wrapper for winsock, plus until this last patch, winsock has been known to have memory leaks.  The install of this product provides some excellent full sample programs (such as FTP, SMTP, TCP/IP, even UDP) and includes the normal windows help files.

This will really kick start your programming skills with all sorts of PC communications.  These samples will provide all the login, download, upload information you will need!

Hope this helps!
ramses, welcome to EE.  I think it would be more useful for the one whom asks a question if the question did not get locked until the question is clear. If you scroll to the bottom of the screen you will see this.

Comments
Comments are intended to be used as a collaboration tool. Many Experts choose to post
their solutions as comments only.

Answers
An answer is a specific solution to a question and should be submitted if it will solve the
questioner's problem and doesn't duplicate a previous comment.

Comment Vs. Answer
If you are unsure of your solution, post it as a comment. Members can accept comments
as solutions and award you Expert Points for them.




I think this community as a whole does not lock questions, so that the one who asks a question can get maximum bang for the points.
Hi DandL, thanks for the post, but I also explained it to Ramses in Community Support.

I think he will become a valuable player ing our community.

The question will now be rejected.

Thanks,
ComTech
Community Support
ramses the rejection does NOT take you out of the running, if you (now) comment, you will then receive the points.

ComTech

This question has been moved back to the Active Questions list.
>I think he will become a valuable player ing our community.

 Yea I think your right. He seems to know his stuff.
ok, I'll keep that in mind for other questions


RooOOOOAaar!
Go get'em ramses  :-)

CT
>RooOOOOAaar!
>Go get'em ramses  :-)


<laugh>DandL</laugh>
Haxom, go see the <PAQ> "Receive and Send Email from VB"

http://devx.experts-exchange.com/jsp/qManageQuestion.jsp?qid=20173019


Hope this helps




Ramses
Hi Haxiom@devx,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Save as PAQ -- No Refund.
    *** I don't think there was a complete answer here.

Haxiom@devx, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
Avatar of Netminder
Netminder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial