Answered by:
asp.net website chat using sockets

Question
-
User603274173 posted
hello community!
im doing a personal projekt which i require some aid since im gone to a halt now.
i am creating a asp.net website chat using sockets, for minimal traffic to the server (and for learning socket programming too)
so far ive been able to send a simple string, a custom oject i created, and recieve answer. all good right?
now my problem is, whenever i debug and i send new messages to the clients the debugger triggers the event ive set up, but thats it. nothing happens on the UI. code runs fine, no error. ive tried using ajax in case it was a need-to-postback problem, but same result.
so, have anyone any idea why nothing is happening? ive been searching for a answer for a while but all chat client tutorials i can find is windows forms clients. is it impossible to use sockets with a website?
any ideas, hints, comments, anything to help me are very welcome.
im using c# language, and i dont understand much of vb, so please keep it in c# if it comes down to coding
Sunday, February 28, 2010 9:45 PM
Answers
-
User1668404196 posted
Then you can use reverse AJAX (Comet server). This will fulfil ur needs...
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, March 1, 2010 11:45 AM
All replies
-
User1668404196 posted
Hi Good day, Don't use sockets in ASP.net Web chat application. Becoz Most of them won't use sockets for web based chats. Instead of sockets, you need to save messages in some sort of database and display it to the client using AJAX.
And in window based IM only, you need to use sockets, Becoz there is no server here, Its like P2P communication...
If you want to learn about sockets then please checkout the below links
http://www.c-sharpcorner.com/UploadFile/bfarley/SocketChatBF11182005013225AM/SocketChatBF.aspx
http://vb.net-informations.com/communications/vb.net_chat_server_program.htm
Monday, March 1, 2010 3:16 AM -
User603274173 posted
Ajax needs to poll the database every few seconds, which is, a completely waste if theres no new messages.
would caching work for a chat?
and ive read most of the socket tutorials on google, and tried them. im just curious why i cant use it in a webapplication so the server can tell the client when new messages needs to be recieved, instead of the client polling the server and yielding 0 new results most of the time.
ajax goes like this:
client logs on. recieves all messages. starts to poll the server every 5 seconds (or when said person types anything), getting new messages or getting nothing.
i would like it to work more like this:
client logs on. recieves all messages.
server broadcasts to clients when new messages arrives and forces clients to do at db update to get new messages
or this:
client logs on. recieves all messages. start to poll the server
database (sql server 2008 or 2005 needed) uses poll caching, if new messages are added, get new messages, else get cached file
Monday, March 1, 2010 5:55 AM -
User1668404196 posted
Then you can use reverse AJAX (Comet server). This will fulfil ur needs...
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, March 1, 2010 11:45 AM