Hello, i have done a simple TCP Client - Server
In my local PC it work but i dont know if i run TCPServer on other pc, it will receive messages from client?
i tryed it with my bro but nothing, i also open and ports... maby isp dont allow open ports (mobile internet)
well can someone try this one plz for and tell me if work...
TCPClient here
static void Main(string[] args)
{
Flood("Your IP", 12345);
}
private static void Flood(string IP, int Port)
{
// Create Socket
TcpClient Client = new TcpClient();
Console.WriteLine("Connecting...");
Client.Connect(IPAddress.Parse(IP), Port);
Console.WriteLine("Write your message.");
Console.WriteLine("---------------------------------");
while (Client.Connected)
{
String Message = Console.ReadLine();
Stream Stre = Client.GetStream();
ASCIIEncoding AEncod = new ASCIIEncoding();
Byte[] Buff = AEncod.GetBytes(Message);
// Kernel - Sending packets to TARGET
Stre.Write(Buff, 0, Buff.Length);
}
//Close TCP
Client.Close();
}
And TCPServer here...
static void Main(string[] args)
{
Start("IP Here", 12345);
}
static void Start(string IP, int Port)
{
TcpListener Listener = new TcpListener(IPAddress.Parse(IP), Port);
Console.WriteLine("Server is starting...");
Listener.Start();
Socket socket = Listener.AcceptSocket();
Console.WriteLine("Connection Accepted!");
Console.WriteLine("---------------------------------");
Byte[] Buff = new Byte[1024];
while (true)
{
int ReceivedMessage = socket.Receive(Buff);
for (int i = 0; i < ReceivedMessage; i++)
{
Console.Write(Convert.ToChar(Buff[i]));
}
Console.Write("\n");
}
}