阿里云服务器连接不上是怎么回事?

qq_35305161 2017-10-30 08:53:39
小白一枚~


这是我做的一个简单的聊天程序,本来是自己写了个服务器代码的,连接没有问题,但是我尝试连接阿里云服务器(今天中午买的)时,出现了连接不上的问题



我的客户端代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

TcpClient tcpClient;

private void button2_Click(object sender, EventArgs e)
{
tcpClient = new TcpClient();
try
{
tcpClient.Connect(this.textBoxIP.Text, Convert.ToInt32(this.textBoxPort.Text));
this.textBoxInfo.Text = "连接成功";
}
catch (Exception ex)
{
MessageBox.Show("连接失败" + ex.Message);
}
}

private void textBox2_TextChanged(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
string message = this.textBoxinput.Text;
this.textBoxInfo.Text = "发送“" + message + "”-" + DateTime.Now.ToShortTimeString() + "\r\n" + this.textBoxInfo.Text;
NetworkStream stream = tcpClient.GetStream();
byte[] byteArray = Encoding.Unicode.GetBytes(message);
stream.Write(byteArray, 0, byteArray.Length);//发送了字节数组
}
}
}


问一下有没有什么办法解决?主要的问题应该是连不上阿里云服务器,我用WINDOWS远程连接可以接上阿里云,但就是用这个客户端连不上。
...全文
495 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

4,356

社区成员

发帖
与我相关
我的任务
社区描述
通信技术相关讨论
社区管理员
  • 网络通信
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧