小白一枚~

這是我做的一個簡單的聊天程式,本來是自己寫了個服務器代碼的,連接沒有問題,但是我嘗試連接阿里云服務器(今天中午買的)時,出現了連接不上的問題

我的客戶端代碼如下:
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遠程連接可以接上阿里云,但就是用這個客戶端連不上。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/108174.html
標籤:網絡通信
上一篇:分析微信資料包 獲取微信號
下一篇:關于nginx請求轉發配置問題
