我正在處理客戶端向cpp服務器發送文件的文件傳輸應用程序。在客戶端,我可以給服務器的域名,但不是IP地址因爲它可能會有所不同。所以任何人都可以告訴我如何通過它的域名獲得服務器的IP地址。我必須將這個邏輯應用於空中應用。謝謝。如何通過我的flex air應用程序的域名查找我的服務器的IP地址?
1
A
回答
0
您可能會認爲NativeProcess API是您的問題的潛在解決方案。
打開該頁面並滾動到底部;注意他們正在調用Python腳本。您可以通過NativeProcess API調用所需的任何終端/控制檯應用程序,並且您可以將該進程的任意數量的參數作爲Vector.<string>()
提供。基本上,我建議你可以嘗試撥打cmd.exe
並通過ping www.your_unique_server.com
。然後,您可以收到通過nativeProcess.standardOutput
返回的回覆,並且Flex/AIR應用將解析IP。這裏有一個簡單的AIR應用程序,我寫這樣做:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<s:layout>
<s:VerticalLayout paddingTop="20" paddingLeft="20"
paddingRight="20" paddingBottom="20"/>
</s:layout>
<s:Label text="Enter a Domain Name:"/>
<s:TextInput id="domainTI" width="100%" text="www.google.com"/>
<s:Spacer height="20"/>
<s:TextArea id="pingsTA" width="100%" height="100%"
text="Provide a domain name and click 'Ping!'"/>
<s:Button label="Ping!" click="initializeAndPing();"/>
<fx:Script>
<![CDATA[
private var nativeProcess:NativeProcess;
// called by the button.
private function initializeAndPing():void
{
if(NativeProcess.isSupported)
{
// make NativeProcess ready for use.
nativeProcess = new NativeProcess();
nativeProcess.addEventListener(
ProgressEvent.STANDARD_OUTPUT_DATA, onPingResult);
nativeProcess.addEventListener(
ProgressEvent.STANDARD_ERROR_DATA, onStdError);
nativeProcess.addEventListener(
IOErrorEvent.STANDARD_INPUT_IO_ERROR, onStdInError);
pingTheHost();
}
}
private function pingTheHost():void
{
pingsTA.text="";
var cmdFile:File = new File("C:\\Windows\\System32\\cmd.exe");
var startInfo:NativeProcessStartupInfo;
startInfo = new NativeProcessStartupInfo();
startInfo.executable = cmdFile;
// The \n special chars are necessary
// for the command to be executed.
var ping:String = "ping " + domainTI.text + "\n" ;
nativeProcess.start(startInfo);
nativeProcess.standardInput.writeUTFBytes(ping);
}
private function onPingResult(e:ProgressEvent):void
{
// you would need to parse the IP from the text string
// captured here to make it available as a variable.
pingsTA.text +=
nativeProcess.standardOutput.readUTFBytes(
nativeProcess.standardOutput.bytesAvailable);
}
private function onStdError(e:ProgressEvent):void
{
trace("StdError: " +
nativeProcess.standardError.readUTFBytes(
nativeProcess.standardError.bytesAvailable));
}
private function onStdInError(e:IOErrorEvent):void
{
trace("StdInError: " + e.toString());
}
]]>
</fx:Script>
</s:WindowedApplication>
要使用的NativeProcess,如在上面的應用程序,你需要一個AIR V2 + SDK(你可以overlay a new AIR SDK,如果你有一個< 2 SDK)和您還需要啓用extendedDesktop
輪廓在您的應用程序,descriptor.xml文件:
<!-- uncomment this node and remove all but "extendedDesktop" -->
<supportedProfiles>extendedDesktop</supportedProfiles>
最後一個念頭:我相信的NativeProcess API需要您的AIR應用程序安裝爲本地應用程序(即用安裝。 exe文件)。但正如你在屏幕截圖中看到的,使用Flash Builder 4+很容易完成。
但是,如果你沒有Flash Builder 4中,則可以隨時write a build script for ADT,其中附帶的AIR SDK。 Rich Tretola撰寫的這篇文章在封裝基礎知識方面做得很好。
最後,這裏就是我的小應用程序看起來像在使用中:
相關問題
- 1. 我的網站服務器的IP地址,而不是域IP
- 2. 查找服務器的IP地址
- 3. 通過IP地址服務的Zend框架應用程序
- 4. 我的AIR應用程序如何與我的服務器通信?
- 5. 域名服務器IP地址
- 6. 如何查找傳出IP地址所屬的應用服務?
- 7. 如何在PHP(CLI)中查找我的服務器的IP地址
- 8. 動態查找服務器IP地址
- 9. 通過apache服務器上的IP地址訪問子域
- 10. 如何查找Mac機器的DNS服務器IP地址?
- 11. 找不到我的服務器的私有IP地址
- 12. 如何查找應用程序使用的所有IP地址?
- 13. 有人可以通過指向我的IP地址在他的域名下服務我的網站文件嗎?
- 14. 如何在EJB中查找服務器的IP地址
- 15. EC2上的節點服務器只能通過IP地址而不是域名
- 16. 其他人如何使用Apache Tomcat訪問我的本地JavaScript應用程序(通過我的IP地址)7
- 17. 服務器的IP地址
- 18. 服務器的IP地址
- 19. 找到我的服務器IP地址與扭曲
- 20. 如何獲取您的應用程序服務器的IP地址
- 21. 如何使用我的公共IP地址使我的xampp服務器公開?
- 22. 如何查找我的服務器的IP爲Microsoft的雲
- 23. 通過PC名稱訪問wamp服務器文件的本地IP地址 - Android應用程序
- 24. 我如何找到一個家庭組中的服務器的IP地址
- 25. 如何把我的域名連接到我的服務器IP地址(阿帕奇)
- 26. 可能的服務器端Flex/AIR應用程序?
- 27. Bash - 如何知道我的Linux服務器IP地址?
- 28. 我如何知道FreeRadius服務器的IP地址?
- 29. 如何查找Web服務使用者的IP地址?
- 30. 尋找域名的IP地址
你應該能夠做到使用域名文件傳輸。當您嘗試這樣做時,您是否遇到錯誤?你需要什麼IP地址? – 2010-06-03 20:54:56