如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
本文由麦可网整理,转载请注明WindowsPhone7网络编程之使用Socket(芒果更新)芒果更新的WindowsPhone7.1版本的API提供了Socket编程的接口,这给WindowsPhone7的网络开发又添加了一把利器,对于WindowsPhone7上的聊天软件开发是一件非常happy的事情。下面用一个小例子来演示一下WindowsPhone7上的Socket编程。用WindowsPhone7上的客户端程序作为Socket客户端,Windows控制台程序作为服务器端,ip取你电脑本机的ip,端口号用8888,实现了WindowsPhone7客户端向服务器端发送消息和接收消息的功能。先来看看演示的效果(1)WindowsPhone7客户端客户端的实现。MainPage.xaml<phone:PhoneApplicationPagex:Class="SocketTest.MainPage"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:Ignorable="d"d:DesignWidth="480"d:DesignHeight="768"FontFamily="{StaticResourcePhoneFontFamilyNormal}"FontSize="{StaticResourcePhoneFontSizeNormal}"Foreground="{StaticResourcePhoneForegroundBrush}"SupportedOrientations="Portrait"Orientation="Portrait"shell:SystemTray.IsVisible="True"><Gridx:Name="LayoutRoot"Background="Transparent"><Grid.RowDefinitions><RowDefinitionHeight="Auto"/><RowDefinitionHeight="*"/></Grid.RowDefinitions><StackPanelx:Name="TitlePanel"Grid.Row="0"Margin="12,17,0,28"><TextBlockx:Name="ApplicationTitle"Text="MYAPPLICATION"Style="{StaticResourcePhoneTextNormalStyle}"/><TextBlockx:Name="PageTitle"Text="Socket测试"Margin="9,-7,0,0"Style="{StaticResourcePhoneTextTitle1Style}"/></StackPanel><Gridx:Name="ContentPanel"Grid.Row="1"Margin="12,0,12,0"><TextBlockFontSize="30"Text="主机IP:"Margin="12,23,0,540"HorizontalAlignment="Left"Width="99"/><TextBoxx:Name="Host"InputScope="Digits"HorizontalAlignment="Stretch"Text="192.168.1.102"Margin="110,6,0,523"/><TextBlockFontSize="30"Text="端口号:"Margin="9,102,345,451"/><TextBoxx:Name="Port"InputScope="Digits"HorizontalAlignment="Stretch"Text="8888"Margin="110,90,0,433"/><TextBlockFontSize="30"Text="发送的消息内容:"Margin="6,180,15