as i don't have a username said , throw reversed engineering u should be able to figure out the encryption key also about cryptography u need to be aware of it
---------------------
in case anyone cant see the example pro4never mentioned (basic server client , here it is , a bit modified with more checks)
client
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace Client1
{
class Program
{
static void Main(string[] args)
{
Socket connection = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
connection.Connect("127.0.0.1", 5555);
while (connection.Connected)
{
Console.WriteLine("client connected to server on ip : 127.0.0.1 and port 5555" + "\n");
Console.WriteLine("client is ready to send packets , please enter some string to be sent as byte array" + "\n");
string buffertobesent = Console.ReadLine();
connection.Send(Encoding.ASCII.GetBytes(buffertobesent));
Console.WriteLine("\n" + "client send to the server this following packets : " + buffertobesent + "\n");
}
Console.WriteLine("disconnected" + "\n");
Console.ReadLine();
}
}
}
server
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
namespace Server
{
class Program
{
static void Main(string[] args)
{
Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
listener.Bind(new IPEndPoint(IPAddress.Any, 5555));
listener.Listen(100);
Socket connection = listener.Accept();
Console.WriteLine("port 5555 is on and accepting all connections from any client" + "\n");
Console.WriteLine("waiting connection" + "\n");
if (connection.Connected)
Console.WriteLine("client connected" + "\n");
byte[] buffer = new byte[1024]; // this will be our client buffer
while(connection.Connected)
{
Console.WriteLine("now we are connected and waiting for packets (buffer to be sent)" + "\n");
byte[] rec = null;
int lenght = connection.Receive(buffer, SocketFlags.None);
if (lenght > 0 && lenght < 1025)
rec = new byte[lenght];
Array.Copy(buffer, rec, lenght);
Console.WriteLine("recived packets(encoding.ascii.getstring(rec) : " + "\n");
Console.WriteLine("\n" + Encoding.ASCII.GetString(rec) + "\n");
}
if (connection.Connected == false)
Console.WriteLine("connection disconnected" + "\n");
if (listener.Connected == false)
Console.WriteLine("listener.connected is false" + "\n");
Console.ReadLine();
}
}
}
feel free to correct if something if wrong , feel free to ask for further explaining :) , thanks and credits goes for pro4never