yangxh88 发表于 2008-7-21 14:10:27

高手来看看

:face (13):
; Start The UDP Services
;==============================================
UDPStartup()

; Bind to a SOCKET
;==============================================
$socket = UDPBind("127.0.0.1", 65532)
If @error <> 0 Then Exit

While 1
    $data = UDPRecv($socket, 50)
    If $data <> "" Then
      MsgBox(0, "UDP 数据", $data, 1)
    EndIf
    sleep(100)
WEnd

Func OnAutoItExit()
    UDPCloseSocket($socket)
    UDPShutdown()
EndFunc
;---以上为服务端,以下为客户端.两个程序发送中文会接收不完全.英文则不会有这种情况,高手指点

UDPStartup()

; Open a "SOCKET"
;==============================================
$socket = UDPOpen("127.0.0.1", 65532)
If @error <> 0 Then Exit

$n=0
While 1
    Sleep(2000)
    $n = $n + 1
    $status = UDPSend($socket, "我发的信息为什么服务器收到就短了呢?" & $n)
    If $status = 0 then
      MsgBox(0, "错误", "当发送 UDP 消息时发生错误: " & @error)
      Exit
    EndIf
WEnd

Func OnAutoItExit()
    UDPCloseSocket($socket)
    UDPShutdown()
EndFunc

[ 本帖最后由 yangxh88 于 2008-7-23 21:21 编辑 ]

yangxh88 发表于 2008-7-21 20:36:30

老大们出来关照一下吧:face (34):

hollandmfq 发表于 2014-5-13 15:41:26

雷锋精神传天下!谢谢分享!
页: [1]
查看完整版本: 高手来看看