hello!
i just need your opinion or explanation on that question:
can we use socket in chat application in asp.net?
because any chat application can be implemented on couple of ways,so when we say socket we say windows application but no web application,because we have the server and clients.
so is there a way to use socket in web application?
thank you.

Dani AI

Generated

Following the thread from , and the pointers from and , a concise, practical path for a web chat in ASP.NET:

Browsers cannot open arbitrary OS-level TCP sockets; they use web protocols such as WebSocket, Server-Sent Events (SSE) or WebRTC data channels. For ASP.NET projects the usual, least-effort pattern is to use a library that handles these transports and fallbacks for you. Microsoft SignalR is the most common choice for ASP.NET/ASP.NET Core: it abstracts connection management, handles automatic fallbacks, and integrates with scale-out options. See the SignalR introduction for details: SignalR introduction.

If a lower-level approach is required, implement a WebSocket endpoint on the server and have the browser use the WebSocket API; confirm the host supports WebSockets (IIS, Kestrel, reverse proxy) and use TLS (wss) in production. Relevant reference pages: WebSocket API on MDN (WebSocket API) and IIS WebSocket protocol support (IIS WebSocket support). For peer-to-peer scenarios, consider WebRTC data channels (RTCDataChannel). Server-side native socket code (System.Net.Sockets) is possible for non-browser clients; browsers still need a web protocol bridge (System.Net.Sockets.Socket API).

Quick checklist and common pitfalls:

  • Pick SignalR for fastest route; it includes scale helpers and backplanes (or use Azure SignalR Service).
  • Ensure host and reverse-proxy forward WebSocket upgrades.
  • Use wss + authentication; plan for scaling and message persistence.
  • Troubleshoot with browser Network/Console (handshake 101), server logs, and verify proxy timeouts.

This covers the modern, practical options beyond polling and setInterval-based AJAX.

Recommended Answers

All 3 Replies

Member Avatar for Member #905211

You can use JavaScript Web Sockets, but they still are not quite there yet. Otherwise you are stuck with the whole setInterval and AJAX way of doing things.

Yes it is very true about this.There are lots of many other way in order to complete this task.It is very interesting work which you are doing.I have solved many this type of work in past.

thank you very much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.