WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

s... Socket Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Check if Port 25 Exists On Localhost


Question:

What is the best way to determine if port 25 for SMTP is running on a localhost? I can check all the different SMTP Service names that MS uses for XP, 2000 and NT but that does not ensure that a system is not running a 3rd party SMTP server on port 25.

Answer:

Maybe attempt an sConnect using the Winsock extender. Just use 127.0.0.1 for the local host address...
bestaddr="127.0.0.1"
AddExtender("wwwsk34i.dll")
socket = sOpen ()
if socket != @FALSE
    status=sConnect (socket, bestaddr, "25");SMTP
    if status != @TRUE
        err=wxGetLastErr()
        msg=wxGetErrDesc(err)
        Message("Winsock Error A %err%",msg)
    else
       sClose(socket)
       Message("Port 25","Responding")
    endif
else
    err=wxGetLastErr()
    msg=wxGetErrDesc(err)
    Message("Winsock Error B %err%",msg)
endif

Exit

Article ID:   W15881
File Created: 2004:03:30:15:41:24
Last Updated: 2004:03:30:15:41:24