下面是实例。 //服务器 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Net.Sockets; using System.Net; using System.Reflection; using System.Diagnostics; using System.Text.RegularExpressions;
namespace msgServer { public partial class frmServer : Form { private Socket socket; private IPAddress myIP; private IPEndPoint endPoint; private int point; private Socket clientSocket; private Assembly ass = null; private System.IO.Stream stream = null; private System.Media.SoundPlayer pl; private string txt; private byte[] bs = new byte[512]; public frmServer() { InitializeComponent(); ass = Assembly.GetExecutingAssembly(); stream = ass.GetManifestResourceStream("msgServer.msg.wav"); pl = new System.Media.SoundPlayer(stream); }
//客户端 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Net; using System.Net.Sockets; using System.Diagnostics; using System.Text.RegularExpressions;
namespace smgClient { public partial class frmClient : Form { private IPAddress IP;//ip private EndPoint endpoint;//point private Socket socket;//socket private System.IO.Stream stream = null; private System.Reflection.Assembly ass = null; private System.Media.SoundPlayer pl = null; private string txt; private byte[] bs = new byte[512];
public frmClient() { InitializeComponent(); ass = System.Reflection.Assembly.GetExecutingAssembly(); stream = ass.GetManifestResourceStream("smgClient.msg.wav"); pl = new System.Media.SoundPlayer(stream); }