霓为衣兮风为裳 2015-07-09 14:08 采纳率: 30%
浏览 1545

c#客户端程序连不上其他服务器程序

这是服务器程序

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Sockets;

namespace SeverConsole {
class Program {
static void Main(string[] args) {
Console.WriteLine("Sever is runing");
IPAddress ip = new IPAddress( new byte[]{127,0,0,1});
TcpListener tcpListener = new TcpListener(ip, 8500);
tcpListener.Start();
while (true) {
TcpClient remoteClient = tcpListener.AcceptTcpClient();
Console.WriteLine(@"有客户端连入,{0}<--{1}", remoteClient.Client.LocalEndPoint, remoteClient.Client.RemoteEndPoint);
}
Console.WriteLine(@"please press 'Q' to exit");
//Console.ReadLine();
ConsoleKey key;
do {
key = Console.ReadKey().Key;
} while (key != ConsoleKey.Q);
}
}
}


这是客户端程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Sockets;
namespace clientConsole {
class Program {
static void Main(string[] args) {
Console.WriteLine("Client is running!");

        TcpClient client;
        for (int i = 0; i < 4; i++) {
             client = new TcpClient();                
            try {
                client.Connect("....", 8500);
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
            Console.WriteLine("connecting successful");
            Console.WriteLine("{0}-->{1}", client.Client.LocalEndPoint, client.Client.RemoteEndPoint);
        }
        ConsoleKey key;
        do {
            key = Console.ReadKey().Key;
        } while (key != ConsoleKey.Q);

    }
}

}


客户端在连接的时候 老是异常
Not recognizing known sRGB profile that has been edited

  • 写回答

2条回答

  • weixin_29617471 2015-07-09 14:35
    关注

    这个错误应该是安卓编译器的问题,可以不用理会

    评论

报告相同问题?

悬赏问题

  • ¥15 socket通信实现多人聊天室疑惑
  • ¥15 DEV-C++编译缺失
  • ¥33 找熟练码农写段Pyhthon程序
  • ¥100 怎么让数据库字段自动更新
  • ¥15 antv g6 力导向图布局
  • ¥15 quartz框架,No record found for selection of Trigger with key
  • ¥15 锅炉建模+优化算法,遗传算法优化锅炉燃烧模型,ls-svm会搞,后面的智能算法不会
  • ¥20 MATLAB多目标优化问题求解
  • ¥15 windows2003服务器按你VPN教程设置后,本地win10如何连接?
  • ¥15 求一阶微分方程的幂级数