|
楼主 |
发表于 2010-5-25 08:57:26
|
显示全部楼层
#Include <ACN_NET.au3>
#include <GUIConstantsEx.au3>
$my_ip=_NetworkGetInternetIP()
UDPStartup()
$GOOEY = GUICreate("aaa", 300, 355)
$edit1 = GUICtrlCreateEdit("", 10, 10, 280, 180)
$ipinput=GUICtrlCreateInput ( "118.251.140.194", 75, 200, 100 , 20 )
$portinput=GUICtrlCreateInput ( "65432", 185, 200, 50 , 20 )
$edit2 = GUICtrlCreateEdit("", 10, 230, 280, 80)
$send=GUICtrlCreateButton ( "发送", 110, 320 , 80 , 30 )
GUISetState()
$socket_recv=UDPBind($my_ip, 65432)
If @error Then
$socket_recv=UDPBind(@IPAddress1, 65432)
EndIf
Local $msg=""
Local $ip=""
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then Exit
$data = UDPRecv($socket_recv,1024,3)
If $data <> "" Then
$data[0]=BinaryToString ($data[0],4)
If GUICtrlRead($edit1)<>"" Then
GUICtrlSetData($edit1,GUICtrlRead($edit1)& @CRLF &$data[1]&"("&$data[2]&") To Me::"& $data[0])
Else
GUICtrlSetData($edit1,$data[1]&"("&$data[2]&") To Me::"& $data[0])
EndIf
EndIf
If $msg=$send Then
$ip=GUICtrlRead ($ipinput)
$port=GUICtrlRead ($portinput)
$socket_send=UDPOpen($ip, $port)
UDPSend($socket_send,StringToBinary(GUICtrlRead($edit2),4))
UDPCloseSocket ( $socket_send )
If GUICtrlRead($edit1)<>"" Then
GUICtrlSetData($edit1,GUICtrlRead($edit1) & @CRLF &"Me To "&GUICtrlRead ($ipinput)&"::"& GUICtrlRead ($edit2))
Else
GUICtrlSetData($edit1,"Me To "&GUICtrlRead ($ipinput)&"::"& GUICtrlRead ($edit2))
EndIf
GUICtrlSetData ($edit2, "" )
EndIf
WEnd
改了下,还是不行,为什么呢?
测试自己电脑时,这个获取到的端口怎么都不是我打开的那个端口,而是每次都不同,是一个1K多的端口,这是什么端口? |
|