WEB开发网
开发学院手机开发Windows Mobile 开发 Windows Mobile上的GPRS连接 基于TcpClient 阅读

Windows Mobile上的GPRS连接 基于TcpClient

 2010-05-06 21:56:00 来源:WEB开发网   
核心提示:ci, ref IntPtr phConnection, uint dwTimeout, ref uint pdwStatus);[DllImport("cellcore.dll")]private static extern IntPtr ConnMgrApiReadyEvent();[DllIm
ci, ref IntPtr phConnection, uint dwTimeout, ref uint pdwStatus);

[DllImport("cellcore.dll")]

private static extern IntPtr ConnMgrApiReadyEvent();

[DllImport("cellcore.dll")]

private static extern int ConnMgrReleaseConnection(IntPtr hConnection, int bCache);

[DllImport("coredll.dll")]

private static extern int CloseHandle(IntPtr hObject);

}

使用GPRSConnection class的时候, 先调用Setup方法创建连接,见以下代码:

public void DoTcpConnection()

{

string url = "www.msn.com";

bool res = GPRSConnection.Setup("http://" + url + "/");

if (res)

{

TcpClient tc = new TcpClient(url, 80);

NetworkStream ns = tc.GetStream();

byte[] buf = new byte[100];

ns.Write(buf, 0, 100);

tc.Client.Shutdown(SocketShutdown.Both);

ns.Close();

tc.Close();

MessageBox.Show("Wrote 100 bytes");

}

else

{

MessageBox.Show("Connection establishment failed");

}

}

上一页  1 2 3 

Tags:Windows Mobile GPRS

编辑录入:coldstar [复制链接] [打 印]
赞助商链接