正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- !include LogicLib.nsh
- !define AF_INET 2
- !define SOCK_STREAM 1
- !define IPPROTO_TCP 6
- Section
- ;Initialize Winsock
- System::Alloc 400
- Pop $0
- System::Call Ws2_32::WSAStartup(i514,ir0)i.r1
- StrCmp $1 0 0 done
- ;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 "80端口被占用"
- ${EndIf}
- ${EndIf}
- System::Call Ws2_32::closesocket(ir1)
- System::Free $2
- Cleanup:
- System::Call Ws2_32::WSACleanup()
- done:
- System::Free $0
- SectionEnd
复制代码
|