是这样!~我是想采用REMOTING的HTTP连接来做一个即时通讯的小软件!~我是想让客户端连接到服务器~然后服务器获得它的IP地址~然后也获得它要联系的人的IP地址!~最后让它俩点对点通信!~
由于我对REMOTING还不怎么了解!~所以我实际上是这么做的我先建立了个叫CLASS1的类!这里面处理从客户端传来的客户端信息
public class Class1 : System.MarshalByRefObject
{
string strXinxi;
public string addmsg(string CustID,string msg)
{
messages.Add(msg); strXinxi = "信息来自:" + CustID + ",消息为:" + msg; MessageBox.Show(strXinxi);
return strXinxi;
}
          }这样我在服务器端用的是个WINDOWS窗体!~里面有个listBox控件!~ private void button1_Click(object sender, System.EventArgs e)
{
HttpChannel channel = new HttpChannel(9932); // 建立HTTP连接管道服务 ChannelServices.RegisterChannel(channel); // 向管道服务注册管道

RemotingConfiguration.RegisterWellKnownServiceType(typeof(Class1),"Class1",WellKnownObjectMode.SingleCall); statusBar1.Text = "服务器状态:已启动"; }在客户端我就是把把连接的服务器地址给写进去!然后把客户信息发给CLASS1 private void button1_Click(object sender, System.EventArgs e)
{
port = int.Parse(textBox3.Text);//客户端连接的端口 ChannelServices.RegisterChannel(new HttpChannel(port)); clianjie = (Class1)Activator.GetObject(typeof(tongyongleiku.Class1),"http://192.168.1.9:9932/Class1"); if(clianjie == null)
{
statusBar1.Text = "状态:无法连接到服务器";
}
else
{
statusBar1.Text = "状态:已连接服务器";
string ComputerName = Dns.GetHostName(); IPHostEntry myHost = new IPHostEntry();
myHost = Dns.Resolve(ComputerName);
string strCIP = myHost.AddressList[0].ToString(); } }这样CLASS1就能收到客户端的信息了!~
可我想在服务器端的LISTBOX里呈现客户端信息!并一直监听它的状态!
可这个我就不知道怎么写了!!!~
1。我怎么把组件CLASS1里返回的值在呈现到LISTBOX里啊?!?!
谢谢大家了!
2。还有就是我思路上有啥问题!?具体这样写行不行也请大家指教