Main proc
LOCAL @Socket:SOCKET
LOCAL @addr:sockaddr_in
LOCAL @Event:HANDLE
LOCAL @NetWork:WSANETWORKEVENTS
LOCAL @wsaData:WSADATA
invoke WSAStartup,202h,addr @wsaData
.while TRUE
mov @Socket,FUNC(socket,AF_INET,SOCK_STREAM,0)
mov @Event,FUNC(WSACreateEvent)
mov @addr.sin_family,AF_INET
mov @addr.sin_addr,FUNC(inet_addr,SADD("127.0.0.1"))
invoke htons,90
mov @addr.sin_port,ax
invoke WSAEventSelect,@Socket,@Event,FD_CONNECT
invoke connect,@Socket,addr @addr,sizeof @addr
.while TRUE
invoke WaitForSingleObject,@Event,INFINITE
invoke WSAResetEvent,@Event
invoke WSAEnumNetworkEvents,@Socket,@Event,addr @NetWork
.if @NetWork.lNetworkEvents & FD_CONNECT
.if BYTE PTR @NetWork.iErrorCode[FD_CONNECT_BIT] != 0
invoke wsprintf,addr buf,SADD("连接失败,错误码:%d"),FUNC(WSAGetLastError)
invoke MessageBox,0,addr buf,0,0
.continue
.endif
invoke wsprintf,addr buf,SADD("连接成功,错误码:%d"),FUNC(WSAGetLastError)
invoke MessageBox,0,addr buf,0,0
.endif
.endw
.endw
mov eax,0
Ret
Main EndP
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!