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

Examples

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

Finger Client Sample Winsock App

Keywords:   finger request 

;**************************************************************************
;		 FINGER CLIENT SAMPLE WINSOCK APP
;
; Usage: Run this file from WinBatch, optionally with 1 param:
;	 Finger.WBT "<your dialup name>"
;
; Author: Jennifer Palonus
; 
;  Date	   Major changes
; -------  ----------------------------------------------------------------
; 13mar96  Created as ClockMan95 WIL script.
; 30apr96  Standalone WBT script (with WXSock WIL extender).
;**************************************************************************
sTitle = "ClockMan Finger pgm"


AddExtender ("wwwsk34I.dll")


;Dial our host, asking first if user has more than 1 defined...
hConn = 0
sDialUps = DUNItemize ()
if (ItemCount(sDialUps,@TAB) == 1)
	sDial = sDialUps
else
	sDial = AskItemList ("Choose a dial-up connection", sDialUps, @TAB, @SORTED, @SINGLE)
endif

hConn = DUNConnect (sDial)
nErr = wxGetLastErr()
if (!hConn)
	select (nErr)
		case @SErrBusy
			Message (sTitle, "Couldn't connect to %sDial%: Line busy.")
			break
		case @SErrNoAnswer
			Message (sTitle, "Couldn't connect to %sDial%: No answer.")
			break
		case @SErrVoice
			Message (sTitle, "Couldn't connect to %sDial%: A human answered.")
			break
		case nErr
			Message (sTitle, "Couldn't connect to %sDial%: Error %nErr%.")
	end select
	exit
endif

sHost = " "
sCmd = " "
while (sHost<>"" && sCmd<>"")
	; Get a finger request...
	sHost = AskLine (sTitle, "Enter the host to query:", sHost)
	if (sHost=="")
		continue
	endif
	sCmd = AskLine (sTitle, "Enter the finger request:", sCmd)
	if (sCmd=="")
		continue
	endif

	; Create a socket...
	hSock = SOpen ()
		if (hSock==@FALSE)
		nErr = wxGetLastErr ()
		Message (sTitle, "Couldn't create socket: %nErr%")
		continue
	endif

	; Connect it up...
	nRet = SConnect (hSock, sHost, "finger")
	if (nRet == @FALSE)
		nErr = wxGetLastErr ()
		Message (sTitle, "SConnect error: %nErr%")
		goto CloseSocket
	endif

	; Send our Finger request...
	nRet = SSendLine (hSock, sCmd)
	if (nRet==@FALSE)
		nErr = wxGetLastErr ()
		Message(sTitle, "Error sending command: %nErr%")
		goto CloseSocket
	endif

	; Get all lines from Finger server till it closes the connection...
	sResponse = ""
	sLine = SRecvLine (hSock, 32767)
	nErr = wxGetLastErr()
	while (nErr==@SOK)
		sResponse = StrCat (sResponse, sLine, @CRLF)
		Yield ()	
		sLine = SRecvLine (hSock, 32767)
		nErr = wxGetLastErr()
	endwhile

	if (nErr <> @SErrNoConn)
		Message (sTitle, "Error receiving response: %nErr%")
	endif

	Message (sTitle, sResponse)

	; Close the socket...
	:Cancel
	:CloseSocket
	if (hSock)
		nRet = SClose (hSock)
	endif
endwhile

; Hang up...
:HangUp
if (hConn)
	nRet = DUNDisconnect (hConn)
endif


Article ID:   W12634
Filename:   Get a Finger Request.txt
File Created: 2001:03:01:15:11:12
Last Updated: 2001:03:01:15:11:12