|
;### Tidy Error: If/ElseIf statement without a then..
If $rdata = $rwindows
EndIf
这个是什么问题啊,帮帮我啊:
本软件是,服务端接收客户端发送消息,判断后给客户端在回个消息,现在遇到以上问题,谁能帮帮我啊-
服务端
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_outfile=..\..\dd12.exe
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\我的文档\Form1.kxf
$Form1 = GUICreate("Form1", 151, 151, 414, 391)
$Button1 = GUICtrlCreateButton("START", 32, 48, 89, 33)
$Button2 = GUICtrlCreateButton("END", 32, 96, 89, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$cfgpath = @ScriptDir & "\config.dat"
$windows = IniRead($cfgpath, "date", "当代网吧", "")
$rwindows = BinaryToString($windows, 4)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button1
tpc()
Case $Button2
Exit
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func tpc()
$g_IP = "127.0.0.1"
TCPStartup()
; 创建监听套接字("SOCKET")
;==============================================
$MainSocket = -1
$MainSocket = TCPListen($g_IP, 65432)
If $MainSocket = -1 Then Exit
; 等待客户端连接
;--------------------
While 1
$ConnectedSocket = TCPAccept($MainSocket)
$szIP_Accepted = SocketToIP($ConnectedSocket)
If $ConnectedSocket >= 0 Then
;MsgBox(0, "", "我的服务器 - 客户端已连接")
$recv = TCPRecv($ConnectedSocket, 2048)
If $recv <> "" Then
$rdata = BinaryToString($recv, 4)
MsgBox(4112, "服务端正确", "接收数据 " & $rdata)
MsgBox(4112, "服务端正确", "发送端IP " & $szIP_Accepted)
;### Tidy Error: If/ElseIf statement without a then..
If $rdata = $rwindows
EndIf
EndIf
EndIf
WEnd
TCPCloseSocket($ConnectedSocket)
EndFunc ;==>tpc
func sendd()
;### Tidy Error: If/ElseIf statement without a then..
If $rdata = $rwindows
EndIf
EndFunc ;==>sendd
Func SocketToIP($SHOCKET)
Local $sockaddr, $aRet
$sockaddr = DllStructCreate("short;ushort;uint;char[8]")
$aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _
"ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr))
If Not @error And $aRet[0] = 0 Then
$aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3))
If Not @error Then $aRet = $aRet[0]
Else
$aRet = 0
EndIf
$sockaddr = 0
Return $aRet
EndFunc ;==>SocketToIP
客户端
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_outfile=..\..\22.exe
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
;客户端
$g_IP = "127.0.0.1"
$szData = StringToBinary("NO", 4)
$szIPADDRESS = @IPAddress1
; 开始 TCP 服务
;==============================================
TCPStartUp()
; 创建一个套接字(socket)连接到已经存在的服务器
;==============================================
$socket = TCPConnect($g_IP, 65432)
If $socket = -1 Then Exit
$recv = TCPSend($socket, $szData) ;传输数据
If @error Then Exit
$rdata = BinaryToString($recv, 4)
MsgBox(4112, "客户端发送", "数据传输ok " & $rdata)
;接受部分
$g_IP = "127.0.0.1"
TCPStartup()
; 创建监听套接字("SOCKET")
;==============================================
$MainSocket = -1
$MainSocket = TCPListen($g_IP, 65432)
If $MainSocket = -1 Then Exit
$ConnectedSocket = TCPAccept($MainSocket)
If $ConnectedSocket >= 0 Then
;MsgBox(0, "", "我的服务器 - 客户端已连接")
$recv = TCPRecv($ConnectedSocket, 2048)
If $recv <> "" Then
$rdata = BinaryToString($recv, 4)
MsgBox(4112, "客户端接收正确", "数据传输ok " & $rdata)
TCPCloseSocket($ConnectedSocket)
EndIf
EndIf
Exit |
|