! IncludeLogiclib. nsh
! DefineAf_inet2
! DefineSock_stream1
! DefineIpproto_tcp6
Section
; Initialize Winsock
System: alloc400
Pop$0
System: Call ws2_32: wsastartup(I514, ir0) I. r1
Strcmp$10 0Done
; Create a socket for listening for incoming connection requests
System: Call ws2_32: Socket (I $ {Af_inet} , I $ {Sock_stream} , I $ {Ipproto_tcp} ) I. r1
Strcmp $1 0 Cleanup
System: Call ws2_32: inet_addr (T "127.0.0.1" ) I. S
System: Call ws2_32: htons (I80) I. s
System: Call "* (& I2 $ {Af_inet} , & I2 S, I s, & T8) I. R2"
; Bind the socket.
System: Call ws2_32: bind (Ir1, ir2, I16) I. r3
$ {If} $3 =- 1
MessageBox Mb_iconinformation | Mb_ OK "BIND () failed ."
System: Call ws2_32: wsagetlasterror () I. r3
$ {If} $3 = 10048
MessageBox Mb_iconinformation | Mb_ OK "Port 80 is in use"
$ {Endif}
$ {Endif}
System: Call ws2_32: closesocket (Ir1)
System: free $2
Cleanup:
System: Call ws2_32: wsacleanup ()
Done:
System: free $0
Sectionend