'TCP/IP routines for real-mode DOS networking in QuickBASIC.
'Coded by Mike Chambers, 2006 - Home page: http://rubbermallet.org/qb
'
'Requirements:
' - Ethernet card and a packet driver, or a dial-up connection.
' If you don't have a packet driver for your card, you
' need to find one that is compatible with yours.
' Crynwr proides free DOS packet drivers for MANY different cards.
' You can find them at http://www.crynwr.com/drivers
'
' - WatTCP (Provides TCP/IP stack. http://www.wattcp.com )
'$INCLUDE: 'c:\users\sureshot\jbridal\qb.bi'
FUNCTION Connect%
(socketID%
, ipAdr$
, portNr%
)
ipBin$ = ""
ipAdr$
= MID$(ipAdr$
, p%
+ 1) ipBin$
= ipBin$
+ CHR$(VAL(ipAdr$
))
'Make sure supplied remote IP is valid.
tcpIn.ax = &H300
tcpIn.cx = 1
tcpIn.dx = socketID%
IF tcpOut.ax
<> 0 THEN 'If error occurs while trying to connect. Connect = 0
PufSeg% = tcpOut.cx
PufOffs% = tcpOut.dx
tcpIn.ax = &H500
tcpIn.dx = socketID%
IF tcpOut.ax
<> 0 THEN 'If connection error occurs. Connect = 0
tcpIn.ax = &HD00
tcpIn.ax = &HB00
tcpIn.dx = socketID%
Connect = 1
SUB Disconnect
(socketID%
)
tcpIn.ax = &HC00
tcpIn.dx = socketID%
tcpIn.ax = &HD00
IF ntemp%
= 32768 THEN FreeSock%
= 0
Continue% = -1
z$ = ""
tcpIn.ax = &H800
tcpIn.cx = 1024
tcpIn.dx = socketID%
'Ignore
'If peer closes the connection.
Continue% = 0
Disconnect socketID%
FOR i%
= 0 TO tcpOut.ax
- 1 z$
= z$
+ CHR$(PEEK(PufOffs%
+ 16 + i%
))
tcpIn.ax = &H800
tcpIn.cx = 0
tcpIn.dx = socketID%
IsOpen = 1
IsOpen = 0
FUNCTION SendData%
(socketID%
, strData$
)
sID% = socketID%
t$ = strData$
Continue% = -1
tcpIn.ax = &H900
tcpIn.dx = socketID%
IF tcpOut.ax
< 0 THEN 'If there is an error sending data. Disconnect (sID%)
SendData = 0
t$
= MID$(t$
, tcpOut.ax
+ 1) SendData = 1
tcpIn.ax = &HE00
VerifyTCP = 0
VerifyTCP = 1