'-------------------------------------------------------------------------------
'                          TCPIP.BAS
'                    (c) 2002-2003 MCS Electronics
'-------------------------------------------------------------------------------

$regfile = "M161def.dat"
$crystal = 4000000
$baud = 19200

Const Sock_stream = $01                 ' Tcp
Const Sock_dgram = $02                  ' Udp
Const Sock_ipl_raw = $03                ' Ip Layer Raw Sock
Const Sock_macl_raw = $04               ' Mac Layer Raw Sock
Const Sel_control = 0                   ' Confirm Socket Status
Const Sel_send = 1                      ' Confirm Tx Free Buffer Size
Const Sel_recv = 2                      ' Confirm Rx Data Size

'socket status
Const Sock_closed = $00                 ' Status Of Connection Closed
Const Sock_arp = $01                    ' Status Of Arp
Const Sock_listen = $02                 ' Status Of Waiting For Tcp Connection Setup
Const Sock_synsent = $03                ' Status Of Setting Up Tcp Connection
Const Sock_synsent_ack = $04            ' Status Of Setting Up Tcp Connection
Const Sock_synrecv = $05                ' Status Of Setting Up Tcp Connection
Const Sock_established = $06            ' Status Of Tcp Connection Established
Const Sock_close_wait = $07             ' Status Of Closing Tcp Connection
Const Sock_last_ack = $08               ' Status Of Closing Tcp Connection
Const Sock_fin_wait1 = $09              ' Status Of Closing Tcp Connection
Const Sock_fin_wait2 = $0a              ' Status Of Closing Tcp Connection
Const Sock_closing = $0b                ' Status Of Closing Tcp Connection
Const Sock_time_wait = $0c              ' Status Of Closing Tcp Connection
Const Sock_reset = $0d                  ' Status Of Closing Tcp Connection
Const Sock_init = $0e                   ' Status Of Socket Initialization
Const Sock_udp = $0f                    ' Status Of Udp
Const Sock_raw = $10                    ' Status of IP RAW



$lib "tcpip.lbx"                        ' specify the tcpip library
Print "Init , set IP to 192.168.0.8"    ' display a message
Enable Interrupts                       ' before we use config tcpip , we need to enable the interrupts
Config Tcpip = Int0 , Mac = 12.128.12.34.56.78 , Ip = 192.168.0.8 , Submask = 255.255.255.0 , Gateway = 0.0.0.0 , Localport = 1000 , Tx = $55 , Rx = $55

'Use the line below if you have a gate way
'Config Tcpip = Int0 , Mac = 12.128.12.34.56.78 , Ip = 192.168.0.8 , Submask = 255.255.255.0 , Gateway = 192.168.0.1 , Localport = 1000 , Tx = $55 , Rx = $55
Do
  nop                                   ' wait for ever
Loop
End