Visual Basic 911 - FAQ (network/Internet)

I wrote the domain scanner, but it's working too slow. How to make it faster?

The best way to make your code faster - multithreading: don't wait until the first socket return you result, but start as many as your system lets you and dispatch messages from them. You can use Visual Basic as well as Visual C++. I've also heard about PowerBuilder and Delphi implementations.

How many Winsock controls can I have simultaneously?

You should play with it to find out. In most cases its limited by RAM. And, of course, you can't have more than 32,767 simultaneous socket connections on Windows (I was never able to get more than 2,000 even on dual Pentium Pro 200 with 256 MB RAM)

How to resolve remote system name?

You can use gethostbyname and gethostbyaddress APIs. Check "Writing the DNS Control" project.

How to add Winsock controls at runtime?

Add Winsock control to your project. Set its Index property to 0. To load more controls during run-time use following code:
    For i = 1 to NumberOfControlsYouNeed
        Load Winsock1(i)
        Winsock1(i).RemoteHost = "..."
        Winsock1(i).RemotePort = ...
        Winsock1(i).Connect
    Next

Do I have to use MAPI to write email client for Windows?

Not at all. Best way to write email client is - using Winsock control. You need to know POP (for reading e-mail) and SMTP (for sending e-mail)

How to connect to the Web server after I wrote the email client using VB?

I think you mean mail, not Web, server. Set RemoteHost property for Winsock control to your server name or IP address.

What things are necessary to write email client using VB?

You need at least Professional Edition (Microsoft doesn't ship Winsock control with Learning or Standard edition). Of course you need Internet connection (dial-up or LAN). You need to look through Winsock control help file, POP and SMTP RFCs. Also you need basic understanding how Internet protocols work.

Do I need VB6 to write email program?

Not really. Nothing much changed in Winsock control from VB4 to VB6

How do I make my program to send email to me during the installation or on the first start?

You can use OstroSoft SMTP component. On the start you can check pre-defined key in Registry and if it's not set (means first use), then send e-mail and set the key

How do I receive email with SMTP control?

You can't. You need POP3-based control for it

I didn't find anything about SMTP in VB help file

check SMTP RFC

How do I learn more about Winsock programming?

There is a great book written by Carl Franklin: "Internet programming with VB"

I've seen email program that doesn't use Winsock control. How come?

It was probably using MAPI. Good for Exchange, not for Internet email.

How do I write a control to post messages to news groups?

There is a great NNTP sample in Carl Franklin's book "Internet programming with VB". There is nothing special in writing NNTP client. You need to know NNTP RFC and how Winsock control works.

What's happened to Portscan/GLAZ/OstroSoft Ping/Domain Scanner/etc? Can't download then anymore.

All these programs are no longer supported as separate applications, but included in OstroSoft Internet Tools. You can download the latest version at http://www.ostrosoft.com/download/full/ostronet.exe

How can I send a text file via email from my VB application?

You can use OstroSoft SMTP component. Open file for input, read it into string variable, set SMTP.MessageBody equal to this variable and send it.

How can I write telnet program with Winsock control?

You need to know Telnet protocol and there is nothing better to explain it than Telnet RFC. You can get it at http://www.cis.ohio-state.edu/htbin/rfc/rfc854.html

How to scan NT network for the machines that are currently running?

Try ADSI. This project might help you http://www.netfokus.dk/vbadmincode/code/netres1.zip

How can I attach files using the SMTP (Winsock)?

You can use OstroSoft SMTP component. Or write SMTP control supporting MIME attachments. There is a bunch of RFCs you need to know.

How can I program Winsock to check my email (POP3)?

Write POP3 client. All you need is to know how Winsock works and POP3 RFC.

I am using OstroSoft Internet Tools 1.1. Where can I download the latest version?

http://www.ostrosoft.com/ostronet.html

What AOL SMTP server is?

run NS Lookup against aol.com - MX records will show you AOL mailservers

How do I write ftp program using VB?

FTP is pretty complicated protocol. There is a control providing stripped-down implementation of FTP - Microsoft Internet Transfer control (MSINET.OCX). It comes with VB 5/6 in Pro/Enterprise versions. There is also help file explaining the usage of control.
I also have sample project on VB 911 - "Transfer files". Though it's not FTP, it uses the same idea (less functionality, of course)

How do I monitor the modem connection using VB?

http://www.zarr.com/vb/download/ccheckduncount.zip

Is it possible to create a Telnet client program in VB5?

It is certainly possible, though it might be a big project. There is a bad sample (the only one I've seen so far) at
http://www.netfokus.dk/vbadmincode/code/telnet.zip

From my workstation I need to read the date/time on the NT server to use as the timestamp for database (I'm using .mdb).

Timestamp in Access uses local system clock, so the only thing you can do - is synchronize it with server clock. You need to have simple TCP/IP services running on NT server. Connect to port 13 (datetime) using Winsock and it will return you a server date/time. Then you can use API to set your workstation clock to time you received.

How can I configure internet transfer control or Winsock control for internet connection over intranet?

There is no special intranet configuration for Inet and Winsock controls. If you are able to connect to internet from your intranet, then you should be able to use these controls. If not - nothing can help you.

How to do a HTTP-POST to a specific address with specific values and get the resulting page (response) as a string?

Say you have form
<form action=action.asp method=post>
name: <input type=text name=name>
<input type=submit>
</form>

You should send something like this:

POST /action.asp HTTP/1.0
Connection: Keep-Alive
Host: www.yourhost.com
Accept: */*

Content-type: application/x-www-form-urlencoded
Content-length: 9

name=Yourname

You can use Microsoft Winsock control for it. On Connect - send header. On DataArrival - get response.

I am making a file transfer and I want the client to tell the server the file extension before it sends.

You can use file transfer project from my website: http://www.ostrosoft.com/vb/projects/transfer.html
You need to change few things, like make it 2-step process:
1)on connect client sends filename to server
2)server store it, responds to client
3)client sends file to server
4)server saves file under temporary name, on transmission end server renames file to previously stored filename

Inet.ocx gets hang sometimes without any response, crashing the whole application. Any suggestions?

inet.ocx is very unstable. I gave up on it long ago. Instead I'm using Winsock control along with HTTP RFC

How do I programmatically get all the records from the DNS server (AA, CNAME, etc...)?

It's pretty complicated. Check RFCs 1034 and 1035 for info on DNS. Use TCP or UDP on port 53.

How can I send email with attachment in VB?

You have few options.
1. Use OstroSoft SMTP component or any other 3rd party components/libraries
2. Using Winsock build your own application supporting SMTP with MIME attachments. It's most difficult way, since you have to learn bunch of RFCs. Use Writing SMTP control project as a sample
2. If you are going to use Exchange server (or any other MAPI-complaint server), your best choice is - Microsoft MAPI controls
3. And, finally, if you have IIS with SMTP on NT server, you can use CDONTS library.

How do I find my SMTP server?

Ask your ISP. ISPs usually have the same server for both SMTP (sending e-mails) and POP3 (receiving e-mails). Or run NS lookup on your domain