I want to make a chat to my site for example. And the server I want to write on with #. Is it possible to do that? For example, hereβs what Iβm saying on the server:
const int port = 8888; // ΠΏΠΎΡΡ Π΄Π»Ρ ΠΏΡΠΎΡΠ»ΡΡΠΈΠ²Π°Π½ΠΈΡ ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΠΉ static void Main(string[] args) { TcpListener server = null; try { IPAddress localAddr = IPAddress.Parse("127.0.0.1"); server = new TcpListener(localAddr, port); // Π·Π°ΠΏΡΡΠΊ ΡΠ»ΡΡΠ°ΡΠ΅Π»Ρ server.Start(); while (true) { Console.WriteLine("ΠΠΆΠΈΠ΄Π°Π½ΠΈΠ΅ ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΠΉ... "); // ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ Π²Ρ
ΠΎΠ΄ΡΡΠ΅Π΅ ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ TcpClient client = server.AcceptTcpClient(); Console.WriteLine("ΠΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ ΠΊΠ»ΠΈΠ΅Π½Ρ. ΠΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ Π·Π°ΠΏΡΠΎΡΠ°..."); // ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠ΅ΡΠ΅Π²ΠΎΠΉ ΠΏΠΎΡΠΎΠΊ Π΄Π»Ρ ΡΡΠ΅Π½ΠΈΡ ΠΈ Π·Π°ΠΏΠΈΡΠΈ NetworkStream stream = client.GetStream(); // ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ Π΄Π»Ρ ΠΎΡΠΏΡΠ°Π²ΠΊΠΈ ΠΊΠ»ΠΈΠ΅Π½ΡΡ string response = "ΠΡΠΈΠ²Π΅Ρ ΠΌΠΈΡ"; // ΠΏΡΠ΅ΠΎΠ±ΡΠ°Π·ΡΠ΅ΠΌ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ Π² ΠΌΠ°ΡΡΠΈΠ² Π±Π°ΠΉΡΠΎΠ² byte[] data = Encoding.UTF8.GetBytes(response); // ΠΎΡΠΏΡΠ°Π²ΠΊΠ° ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΡ stream.Write(data, 0, data.Length); Console.WriteLine("ΠΡΠΏΡΠ°Π²Π»Π΅Π½ΠΎ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅: {0}", response); // Π·Π°ΠΊΡΡΠ²Π°Π΅ΠΌ ΠΏΠΎΡΠΎΠΊ stream.Close(); // Π·Π°ΠΊΡΡΠ²Π°Π΅ΠΌ ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ client.Close(); } } catch (Exception e) { Console.WriteLine(e.Message); } finally { if (server != null) server.Stop(); } } How can I make a simple client for this server?
const io = require("socket.io-client"), ioClient = io.connect("http://localhost:8888"); ioClient.on("seq-num", (msg) => console.info(msg)); Connected, but messages do not come. I do not delve into this node. I did not find an example of this type on the Internet. How to dig, where to dig, what to read to understand?