| Author |
Topic |
|
AfterMath
Starting Member
19 Posts |
Posted - 2002-06-13 : 19:01:15
|
| i wrote a chat program for my graduation project which is like icq.I'm using SQL server 2000 as a server for this client.I made 5 sec checks to the SQL server for the users logging on or off but this's quite bad and slows the server.i'm searching for an answer for this:can sql server send clients something when a user on his/her contactlist goes online or offline?A friend said that i can make it with "stored procedures"?But i don't know stored procedures. Can you help me?Edited by - AfterMath on 06/13/2002 19:02:24 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-06-13 : 19:27:26
|
| eeeeeeeeeeeeeeeeeewwwwwwwwwwwwwwwwwwwwYes, you will have performance problems if each client connection keeps reconnecting every 5 seconds, or polling the connection, stored procedures or not.SQL Server is FAR from optimal as a communication intermediary. As far as storing user information it's fine, but once that information is passed to the client connection there should be very little if any network traffic. The only connection to SQL Server should strictly be for updating information in the database. Please tell me you're NOT logging the chat contents in the database.This is really a network communication issue, there's not much you can do with SQL Server to improve performance except to minimize the amount of network traffic going through it. If you need some hints (don't know if you can research outside code or not) check some of these ASP sites, they have chat programs that do not require a database:www.4guysfromrolla.comwww.15seconds.comwww.asp101.comwww.aspalliance.comwww.learnasp.com |
 |
|
|
AfterMath
Starting Member
19 Posts |
Posted - 2002-06-13 : 20:46:12
|
| i found something like this in your site:xp_getnetnameThis extended stored procedure returns the WINS name of the SQL Server that you're connected to. To view the name, run:EXEC master..xp_getnetnameif a user logs on, we can send this message to the client. And it can work like a boolean?Can i do this?I didn't log the chat contents to the server but i'm thinking to do it. Because winsock is a very bad compenent. I hate it. And i made this preject on VB so i don't need any asp sites:(If a load so many winsocks the clients memory goes very low. So it's better to log it to the server. As a result, you are saying that there's no way that sql server can send me something? Right?Thanks |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-06-13 : 21:09:06
|
quote: i made this preject on VB so i don't need any asp sites
OK, first, I'm trying to help you. If you actually went to the ASP sites and reviewed the code, instead of copping an attitude, you'd find that they're written in VBScript which you could most likely copy and paste into your VB project. If not, you'd certainly get ideas from established, functioning code that does not suffer the problems you're having now.Second, the point is NOT to use SQL Server because it is a DATABASE product, not a network communication product. You're shuffling packets between clients, you don't need a server at all (think of a P2P setup). Or, at the MOST, the server is simply a switchboard or router for the chatting clients.Next, Winsock is a bad component...SO DON'T USE IT. And again, if you went to the ASP sites, you'd find alternatives to Winsock. Why don't you take a look there, and maybe try the message boards at 4Guys, you'll find a bunch of people there who are more knowledgeable about this than either one of us. If you're opening multiple sockets to chat with each client, you're probably doing it wrong.If you absolutely have to store the contents in the database (which is a bad idea IMHO) then you should have each client open a connection to SQL Server ONCE, and keep it open until the chat terminates. There's no need to poll SQL Server unless you've got a dodgy connection, which kinda kills the whole process anyway...but I digress. The chat contents should be passed to SQL Server to be INSERTed into the logging table. The best way to do that is to use a stored procedure. This database part should be the last thing you do in the whole program, and it should be totally independent of the network transport between the chatting clients.Go back to those ASP sites, and check any VB sites you know of. I'll recommend these as well, although you seem to feel you don't need them:www.vb2themax.comwww.swynk.comwww.mvps.org |
 |
|
|
AfterMath
Starting Member
19 Posts |
Posted - 2002-06-14 : 12:13:23
|
| Thank you robvolk but let me put it like this:what's a stored procedure?are they running in the server?Can they send me something from server to my client program if i code it?i have the book of thearon willis." beginning sql server 2000 for vb developers"i took a look at the stored procedures part.and also i found a place in the sql server where there are a lot of stored procedures.can you name me a stored procedure that is sending me something when the database is changed?Thanks again...looking forward |
 |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2002-06-14 : 12:32:56
|
| AfterMath,I've done something along the same lines.I had a trigger on a table that fires whenever someone UPDATES a record. That Trigger called a VB EXE. The VB EXE got command line parameters from the Trigger, and used winsock to connect to a destination PC over TCP/IP. The Detination PC had a WinSock app "listening" for the TCP/IP data.I think that's about what you need to do. Instead of a VB EXE, you could use a VB ActiveX DLL (COM object).I can't give you any code etc from that project, because someone would hang me. I think if you know anything abotu VB + winsock and do a bit of reading, you can write this. One word of warning.....the EXE that is called in the trigger, make SURE it terminates. If it gets stuck, so does your database.Things to look up:Triggers xp_cmdshellMichael |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2002-06-14 : 12:41:01
|
| Dude, you are trying to square-peg a round hole, what you really need is a big friggin hammer.<O> |
 |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2002-06-14 : 13:16:32
|
| What should happen is that during startup, check to see who is online.Then whenever some goes offline/online, send a msg to the people who have that use in their contact list to let that client know of the state change.Actual chat needs to be point-to-point. It should not go though SQL server for the chatting part.<rant>Speaking of square pegs and round holes, what are they teaching people in college these days? I'm 23 years old and I only went to college long enough to figure out those guys don't know ANYTHING about real-world problems and solutions. I almost always seem to come up with better solutions than people that are graduating / graduated from college. Since when is polling a good idea? It should usually be avoided at all costs. Thousands of dollars and years out of your life to learn stuff that is wrong or useless in the real world. But there are the parties.....</rant>Michael |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-06-14 : 13:31:38
|
| Aftermath-What MichaelP and Page47 have stated is basically what I wanted to say, and I apologize for coming off like an asshole before. The point is, for a chat program, SQL Server should not be part of it. For the sake of storing a buddy list, yes, that's fine. But as MichaelP suggested, you should connect, get the data, and close the SQL Server connection at the time the client first starts the chat program. The most that your stored procedure would have to do is pass the login name of the user (like an ICQ number or Yahoo name) to the SQL Server to look up the data for that user, and return it to the client. It's very basic:CREATE PROCEDURE GetUserData @userid varchar(50) ASSELECT * FROM UserDateTable WHERE UserID=@useridThat's it. The reason to use a stored procedure is that it will be faster and more secure than using a dynamic SQL string.As far as this assignment goes, if your professor or TA or whoever you're doing this for suggested that you use SQL Server for a chat program, go and rip their balls off so they cannot have children and further pollute the human genome. They've got you barking up the wrong tree. Michael is 150% correct on that, there is absolutely zero real world practicality to that approach. You'd be better off using smoke signals or a coffee-can and fishing-line rig as a chat system. |
 |
|
|
M.E.
Aged Yak Warrior
539 Posts |
Posted - 2002-06-14 : 13:36:35
|
quote: You'd be better off using smoke signals or a coffee-can and fishing-line rig as a chat system
would that be stored as a BLOB field or would it be better to just store the link to the can and string?-----------------------Take my advice, I dare ya |
 |
|
|
AfterMath
Starting Member
19 Posts |
Posted - 2002-06-14 : 17:47:46
|
Michael,i understood what you said. I know vb + winsock.But that trigger things is very bad. Although i know sql, i don't know triggers and such things...can you give a sample trigger example just to make me sure what's going on?Also i found xp_cmdshell on the sql server. thanks. This thing is for running dos commands in the server machine?quote: AfterMath,I've done something along the same lines.I had a trigger on a table that fires whenever someone UPDATES a record. That Trigger called a VB EXE. The VB EXE got command line parameters from the Trigger, and used winsock to connect to a destination PC over TCP/IP. The Detination PC had a WinSock app "listening" for the TCP/IP data.I think that's about what you need to do. Instead of a VB EXE, you could use a VB ActiveX DLL (COM object).I can't give you any code etc from that project, because someone would hang me. I think if you know anything abotu VB + winsock and do a bit of reading, you can write this. One word of warning.....the EXE that is called in the trigger, make SURE it terminates. If it gets stuck, so does your database.Things to look up:Triggers xp_cmdshellMichael
|
 |
|
|
AfterMath
Starting Member
19 Posts |
Posted - 2002-06-14 : 17:52:03
|
Michael,I was just thinking what you wrote about what to do...But i know that i can't do that trigger thing...:(But i'll give it a try...For the rant part, i'll be a Computer Engineer in a months time...And i'm just 22.5...But to tell to truth, after you graduate from a college or a uni, you will be paid more money...That's the facts.quote: What should happen is that during startup, check to see who is online.Then whenever some goes offline/online, send a msg to the people who have that use in their contact list to let that client know of the state change.Actual chat needs to be point-to-point. It should not go though SQL server for the chatting part.<rant>Speaking of square pegs and round holes, what are they teaching people in college these days? I'm 23 years old and I only went to college long enough to figure out those guys don't know ANYTHING about real-world problems and solutions. I almost always seem to come up with better solutions than people that are graduating / graduated from college. Since when is polling a good idea? It should usually be avoided at all costs. Thousands of dollars and years out of your life to learn stuff that is wrong or useless in the real world. But there are the parties.....</rant>Michael
|
 |
|
|
AfterMath
Starting Member
19 Posts |
Posted - 2002-06-14 : 18:06:50
|
Rob,It's ok.I like adodc and sql server and will use it for the project. But if i can not do it with adodc i'll pass to winsock:(I appreciate that you wrote a sample code for me. But i need a code (stored procedure) that can send me something when the table is changed... I wonder if it is hard to do? Thanksnote: I really like this forum, everybody is so understanding and ready to help... :)quote: Aftermath-What MichaelP and Page47 have stated is basically what I wanted to say, and I apologize for coming off like an asshole before. The point is, for a chat program, SQL Server should not be part of it. For the sake of storing a buddy list, yes, that's fine. But as MichaelP suggested, you should connect, get the data, and close the SQL Server connection at the time the client first starts the chat program. The most that your stored procedure would have to do is pass the login name of the user (like an ICQ number or Yahoo name) to the SQL Server to look up the data for that user, and return it to the client. It's very basic:CREATE PROCEDURE GetUserData @userid varchar(50) ASSELECT * FROM UserDateTable WHERE UserID=@useridThat's it. The reason to use a stored procedure is that it will be faster and more secure than using a dynamic SQL string.As far as this assignment goes, if your professor or TA or whoever you're doing this for suggested that you use SQL Server for a chat program, go and rip their balls off so they cannot have children and further pollute the human genome. They've got you barking up the wrong tree. Michael is 150% correct on that, there is absolutely zero real world practicality to that approach. You'd be better off using smoke signals or a coffee-can and fishing-line rig as a chat system.
Edited by - AfterMath on 06/14/2002 18:09:09 |
 |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2002-06-14 : 18:15:40
|
| AfterMath....about the more money thing.....that's not always true in the real world. I make as much if not more than the people with degrees for the simple fact I have TONS more real-world experince than those guys. So instead of having a huge bill to pay after 4 years, I've been making money for four years, and have lots of real-world experience. Your mileage may vary though.About the triggers thing, do you have access to SQL Server's Books Online? If so look there. if not, I can post some info from BOL on here for ya.Michael |
 |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2002-06-14 : 19:06:33
|
| AfterMath... What do you mean by "send me something when the table is changed"? What do you want sent? An email message? And MSMQ message? A picture postcard from Hawaii?As for those of you who think more education will help you earn more, I suggest you run out and buy the July 2002 issue of Business 2.0 magazine and read the cover story titled, "What is an MBA worth?". You won't like the answer. |
 |
|
|
AfterMath
Starting Member
19 Posts |
Posted - 2002-06-14 : 21:40:56
|
I don't know the link of SQL Server's Books Online?if you can give me, it will be real good.Thanksquote: AfterMath....about the more money thing.....that's not always true in the real world. I make as much if not more than the people with degrees for the simple fact I have TONS more real-world experince than those guys. So instead of having a huge bill to pay after 4 years, I've been making money for four years, and have lots of real-world experience. Your mileage may vary though.About the triggers thing, do you have access to SQL Server's Books Online? If so look there. if not, I can post some info from BOL on here for ya.Michael
|
 |
|
|
AfterMath
Starting Member
19 Posts |
Posted - 2002-06-14 : 21:45:10
|
you are funny Mark.maybe it can send me a bid piece of applie pie:)Anyway, i need the usernames of people who are going online or offline. That's what i want from the server...And by the way, i don't think that i'll make an mba.:)Just plain Computer Engineer + a master about a topic will be good for me ...Thanksquote: AfterMath... What do you mean by "send me something when the table is changed"? What do you want sent? An email message? And MSMQ message? A picture postcard from Hawaii?As for those of you who think more education will help you earn more, I suggest you run out and buy the July 2002 issue of Business 2.0 magazine and read the cover story titled, "What is an MBA worth?". You won't like the answer.
|
 |
|
|
AfterMath
Starting Member
19 Posts |
Posted - 2002-06-17 : 12:06:20
|
| Thank you guys...but i couldn't solve my problem...i think for the graduation project i'll keep on with the 5 seconds then after graduating from the school, i will try to find a solution...Edited by - AfterMath on 06/17/2002 12:07:13 |
 |
|
|
|