sproxy
Full Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору Сервер: Код: UDPStartup() $socket = UDPBind(@IPAddress1, 18001) If @error <> 0 Then Exit $n = 0 While 1 $data = UDPRecv($socket, 500) If $data <> '' Then MsgBox(0, 'Server', $data, 1) ; комент $data = '' EndIf Sleep(100) $n += 1 ;~ $status = UDPSend($socket, 'Server message #' & $n) ;~ If $status = 0 then ;~ MsgBox(0, 'ERROR', 'Error while sending UDP message: ' & @error) ;~ Exit ;~ EndIf WEnd Func OnAutoItExit() UDPCloseSocket($socket) UDPShutdown() EndFunc | Клиент: Код: UDPStartup() $socket = UDPOpen(@IPAddress1, 18001) If @error <> 0 Then Exit $n = 0 While 1 $status = UDPSend($socket, 'Client message #' & $n) If $status = 0 then MsgBox(0, 'ERROR', 'Error while sending UDP message: ' & @error) Exit EndIf Sleep(100) $n += 1 $data = UDPRecv($socket, 500) If $data <> '' Then MsgBox(0, 'Client', $data, 1) $data ='' EndIf WEnd Func OnAutoItExit() UDPCloseSocket($socket) UDPShutdown() EndFunc | |