简体   繁体   中英

How do I send message from c# form application to Socket.io application

I found these two examples on net one is socket.io application and second is c# form application which are server client based applications which works fine but when I try to establish communication between c# form application and socket.io application I can not see messages send from c# form application.I am running socket.io application as my server and c# form application as my client and used same port number on both side and given my server's Ip to c# form application in client section. I think it does not receive data because index.html first ask for nickname then it shows messages send from that user.what should I do so that first received message will be considered as user name and then remaining messages will be displayed on web page along with username.I needed username because I want to send messages from index.html to c# form application also.Please help I am trying to achieve this from like three weeks.Thank you.

 C# supports TCP sockets: 
 1) You must need a IpAddress and Port number to connect. 
  Socket socket = new 
  System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork,
                        System.Net.Sockets.SocketType.Stream, 
   System.Net.Sockets.ProtocolType.Tcp);
        try
        {
            byte[] bytes = new byte[256];

            IPAddress ipAdd = System.Net.IPAddress.Parse(ipAddress);
            IPEndPoint remoteEP = new IPEndPoint(ipAdd, port);
            if (Session["IsPortConnected"] == null)
            {
                socket.Connect(remoteEP);
            }
         }


 If this answer helped you please mark it correct. 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM