Home > other >  Ali cloud server connection is not on how to return a responsibility?
Ali cloud server connection is not on how to return a responsibility?

Time:10-04

The small white one ~


This is a simple chat program, I do write a server code originally, connection is no problem, but I try to connect ali cloud server (buy) at noon today, the connection is not on the problems



My client code is as follows:

Using System;
Using System. Collections. Generic;
Using System.Com ponentModel;
Using System. The Data;
Using System. Drawing;
Using System. Linq;
Using System.Net.Sockets;
Using System. The Text;
Using System. The Threading. The Tasks;
Using System. Windows. Forms;

The namespace WindowsFormsApp2
{
Public partial class Form1: Form
{
Public _click ()
{
InitializeComponent ();
}

TcpClient TcpClient.

Private void button2_Click (object sender, EventArgs e)
{
TcpClient=new tcpClient ();
Try
{
TcpClient. Connect (enclosing textBoxIP. Text, Convert the ToInt32 (this) textBoxPort) Text));
This. TextBoxInfo. Text="successful connection";
}
The catch (Exception ex)
{
MessageBox. Show (" connection "+ 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="send" "+ message +" "-" + DateTime. Now the ToShortTimeString () + "\ r \ n" + enclosing textBoxInfo. Text;
NetworkStream stream=tcpClient. GetStream ();
Byte [] byteArray containing=Encoding. Unicode. GetBytes (message);
Stream. Write (byteArray containing, 0, byteArray containing. Length);//send the byte array
}
}
}


Ask is there any way to solve? The main problem should be not on ali cloud server, I use WINDOWS remote connection can mount ali cloud, but are connected with the client is not on,
  • Related