Page 1 of 6 1234 ... LastLast
Results 1 to 40 of 215

Thread: [VB6] - Multi-User Chat Example (Winsock)

Hybrid View

  1. #1

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    [VB6] - Multi-User Chat Example (Winsock)

    I wrote this last night out of boredom and after reading a lot of posts about people wanting to make a basic multi-user chat room.

    This is the most stripped-down code I could come up with that does things "correctly". For that reason, some of the code may seem more complex than it needs to be but I commented it pretty well.

    I am going to write a tutorial to go along with it, as soon as I get free time.

    One common mistake a lot of client/server programs make is they don't program according to the TCP (streaming) protocol. Sometimes "packets" get split up, truncated, sent together, etc. and this data arrival event is coded to expect that and handle it smoothly.

    I set it up so you can add in your own commands easily to the Data Arrival event.

    If you have any questions/comments/suggestions, post them here. I kept out most features like private messages, file transfers, web cams, etc. to keep things simple and straightforward, but if someone wants something added in here let me know.
    Attached Images Attached Images  
    Attached Files Attached Files

  2. #2
    Lively Member
    Join Date
    Aug 2007
    Posts
    107

    Re: [VB6] - Multi-User Chat Example (Winsock)

    did i make you want to start this?

    BTW, thanks for helping me out

  3. #3

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Quote Originally Posted by MrMakealotofsmoke
    did i make you want to start this?
    Yes, actually, your thread (and a few others) is what inspired me to write this.

    Quote Originally Posted by MrMakealotofsmoke
    BTW, thanks for helping me out
    You're welcome.

  4. #4
    New Member Debug.Assert's Avatar
    Join Date
    Aug 2007
    Posts
    4

    Re: [VB6] - Multi-User Chat Example (Winsock)

    This is a nice lil project.
    Is there a way that the Server could remove a user from the server and prevent their return?
    What are some safe (safe = not likely to be in use) ports that can be used other than your default "1234"?

    Thanks for sharing this.

  5. #5

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Quote Originally Posted by Debug.Assert
    This is a nice lil project.
    Is there a way that the Server could remove a user from the server and prevent their return?
    What are some safe (safe = not likely to be in use) ports that can be used other than your default "1234"?

    Thanks for sharing this.
    Along with Hell-Lord's post, here's another list:
    http://www.governmentsecurity.org/ar...ommonPorts.php

    To remove a user from the server, do you mean to ban them? By IP? If you like, I can add that in there real quick.

  6. #6
    New Member Debug.Assert's Avatar
    Join Date
    Aug 2007
    Posts
    4

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Quote Originally Posted by DigiRev
    To remove a user from the server, do you mean to ban them? By IP? If you like, I can add that in there real quick.
    Yes, thats what I meant. To remove a person from the chat "room"

  7. #7
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Service Port
    HTTP 80
    FTP 20,21
    Gopher 70
    SMTP 25
    POP3 110
    Telnet 23
    Finger 79
    Local loops/callbacks 0
    Here are some publicly acceptable ports for the corresponding commuincation types.

  8. #8
    Fanatic Member
    Join Date
    Aug 2003
    Posts
    601

    Re: [VB6] - Multi-User Chat Example (Winsock)

    how about allowing people to change the text colour? not how you have it now.

    but if a user bolds there text, it will be bold on the other clients comps too. know what i'm saying? This is what I am having difficulty doing atm.

  9. #9

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: [VB6] - Multi-User Chat Example (Winsock)

    I'll add in text font/color/b/i/u, and IP banning. And I guess private messages while I'm at it.

  10. #10
    Fanatic Member
    Join Date
    Aug 2003
    Posts
    601

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Heres some more things you can add. invite only chats (must be in the chat room and invite someone to enter), password chats,and set a user limit on chats.

    Allready have password chats in my messenger. working on invite only chats now. kinda like mIRC channel modes.

  11. #11

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Thanks psycho.

    I've decided since I'm adding in these other things I might as well make it multi-room also like mIRC. So next update will have:

    • Private messages
    • Font, color, bold/italic/underline, etc.
    • Multiple rooms
    • Invites to rooms
    • Private and passworded rooms
    • Other things like hyperlinks


    Thanks for all the ideas, if anyone has anymore let me know.

  12. #12
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Im waiting for it Digi.

  13. #13
    Fanatic Member
    Join Date
    Aug 2003
    Posts
    601

    Re: [VB6] - Multi-User Chat Example (Winsock)

    if he don't updateit soon. i'll update his source =)

  14. #14

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Sorry I've been busy with work and other projects but I've already almost finished the update (which is a pretty big update). It will be uploaded tomorrow.

  15. #15
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Ever tried smileys?
    The only way I got it to work once was with the copy-from-clipboard method to RTF-box.
    Delete it. They just clutter threads anyway.

  16. #16

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Quote Originally Posted by TheBigB
    Ever tried smileys?
    The only way I got it to work once was with the copy-from-clipboard method to RTF-box.
    You can insert them directly into the .TextRTF property but I prefer the clipboard method because the other one can be buggy from my experience. I've got so many other projects going on right now I don't know if I will get the smilies put in.

    If you want smilies, then apparently you can ask psycho to put them in since he is planning on updating this code anyway.

  17. #17

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Sorry for another post. I've decided to just start from scratch and keep this first one as a basic example. The one I'm working on now will have more features than what is listed, so I hope this will satisfy everyone. It will be up sometime tomorrow afternoon/evening.

  18. #18

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Sorry it's taking so long. I've gotten a lot of requests from people to add in even more features.

    So I'm working on file transfers, web cameras, whiteboard, and more. You can visit this program's new website:

    http://www.dannydotguitar.com/VBChat/

    The site is new but I will be updating it so check back.

  19. #19
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: [VB6] - Multi-User Chat Example (Winsock)

    I cant download your chat app on your website.

  20. #20

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: [VB6] - Multi-User Chat Example (Winsock)

    It's coming soon. I've been working on a website for someone and it's taking all my time, but it's paying good money.

    So I haven't given up on it or anything.

  21. #21
    Junior Member
    Join Date
    Sep 2007
    Posts
    29

    Re: [VB6] - Multi-User Chat Example (Winsock)

    have you given up yet digirev? or you just been busy? haha, just want to see if this project is still active.

  22. #22
    New Member
    Join Date
    Oct 2007
    Posts
    9

    Re: [VB6] - Multi-User Chat Example (Winsock)

    I am having troubles, me and my friend are trying this, and it works when he hosts the server but when i host he cant connect, it tells him he timed out, I tried turning off my firewall and it still gives him the time our message, has this happened to anybody else?

  23. #23
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: [VB6] - Multi-User Chat Example (Winsock)

    you probably connect to the net with a router.
    am I correct?

    You'd need to set up an UPnP configuration.
    Dunno how to do that, but solves problems for p2p applications.
    Delete it. They just clutter threads anyway.

  24. #24
    New Member
    Join Date
    Oct 2007
    Posts
    9

    Re: [VB6] - Multi-User Chat Example (Winsock)

    ok ill look into it, I have never heard of that before

  25. #25
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Here is a problem i encountered.

    On my computer i run the server appkication
    2. on another computer i cannot connect to the ip. Why?
    Do i have to use telnet or what?

  26. #26
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: [VB6] - Multi-User Chat Example (Winsock)

    what does the ip look like?
    is it in the ranges:

    10.0.0.0 - 10.255.255.255
    172.16.0.0 - 172.31.255.255
    192.168.0.0 - 192.168.255.255

    btw, NAT traversal is the part I meant in the UPnP technologies
    Last edited by TheBigB; Oct 21st, 2007 at 05:03 AM.
    Delete it. They just clutter threads anyway.

  27. #27
    New Member
    Join Date
    Oct 2007
    Posts
    9

    Re: [VB6] - Multi-User Chat Example (Winsock)

    192.168 range, class c i believe, and holy crap I am lost with all this upnp and NAT traversal crap, I cant find any download links or anything
    Last edited by werny; Oct 21st, 2007 at 09:07 AM.

  28. #28
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: [VB6] - Multi-User Chat Example (Winsock)

    an ip in the ranges I mentioned is a 'private' ip.
    it's your computer's ip within a network.
    your network connects to the internet through a router. (which in for example my case is the wireless router)
    the router has the public ip; the ip that connects you to the world. connections go to the router, and the router determines the destination of the packets within that private network.

    problem is; winsock doesn't know what computer it should target behind the public ip.

    you probably have the router and you act as server within the private network.
    your friend sends a packet to your router, but as there is no further destination info the router doesn't know what to do with the packet so it dumps it.
    Delete it. They just clutter threads anyway.

  29. #29
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Re: [VB6] - Multi-User Chat Example (Winsock)

    My ip looks like 192.168.1.72. Is there still a way where this can work? I never worked with winstock.

  30. #30
    Junior Member
    Join Date
    Sep 2007
    Posts
    29

    Re: [VB6] - Multi-User Chat Example (Winsock)

    you would need to setup port forwarding on your router. Log into your router, i'm not going to go into details on this, you can do a google search for the model number of your router and should find some kind of documentation. you need to forward the port that you're trying to connect on (example: port 2000) to your computers local IP (in your case 192.168.1.72). This lets the router know that if a connection comes in on 2000 that it should relay the connection to your IP. Without the port forward the router would deny the request.

  31. #31
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: [VB6] - Multi-User Chat Example (Winsock)

    http://portforward.com/english/route...outerindex.htm
    of course an automatic alternative would be better for an application.
    Delete it. They just clutter threads anyway.

  32. #32
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Woot i got it to work i had to alter the ports telling it which ones to use. I have a few question.

    1. Is there a way to restreive the list of online users and put them in a listbox? This listbox differs from the one in the chat window.

    2nd. Is there a way with this code where i can add a button and make a new chat window and be able to privite chat with a selected user?

    Thx!

  33. #33
    Fanatic Member
    Join Date
    Aug 2003
    Posts
    601

    Re: [VB6] - Multi-User Chat Example (Winsock)

    try changing the ip address to localhost. it will connect to yourself no matter what. i'm also about to release sim-chat as open source. link in sig =]

  34. #34
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Re: [VB6] - Multi-User Chat Example (Winsock)

    May i have an example?

  35. #35
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Re: [VB6] - Multi-User Chat Example (Winsock)

    I have a question i have this code and i and wondering if this can be inserted into the messenger above. There is a problem thought evertime it send the smile it will popup with your picture editor to show the picture. Can this be added to the code above to send smileys?

    vb Code:
    1. Private Sub Command1_Click()
    2. 'First, just add plain text:
    3. rchText1.SelText = rchText1.SelText & "Guest: " & Text1 & vbCrLf
    4.  
    5. 'Then change what needs to be changed to pictures:
    6. RefreshPics
    7. DoEvents
    8. rchText1.SelStart = Len(rchText1.Text) 'Put the start at the end, thats where you want to add the next line
    9. Text1 = ""
    10. Call Text1.SetFocus
    11. End Sub
    12.  
    13. Private Sub Form_Load()
    14. rchText1.OLEObjects.Clear 'Clear the ole objects to prevent errors
    15. End Sub
    16.  
    17. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    18. DoEvents
    19. rchText1.OLEObjects.Clear 'You must add this or the
    20.                             'program will crash. This doesnt
    21.                             'happen in Windows 2k
    22. DoEvents
    23. End Sub
    24.  
    25. Sub RefreshPics() 'This scans the text for :) and (l)'s to change
    26. Dim lFoundPos As Long           'Position of first character
    27.                                         'of match
    28. Dim lFindLength As Long         'Length of string to find
    29.  
    30. Dim MakeSure As Boolean 'I have this to do the procedure twice, just to "make sure"
    31.  
    32.  
    33. GoTo Skip:
    34. Start:
    35. MakeSure = True
    36. Skip:
    37.  
    38. lFoundPos = rchText1.Find(":)", 0, , rtfNoHighlight)
    39.         While lFoundPos > 0
    40.           rchText1.SelStart = lFoundPos
    41.           'The SelLength property is set to 0 as
    42.           'soon as you change SelStart
    43.           rchText1.SelLength = 2
    44.           rchText1.SelText = ""
    45.           rchText1.OLEObjects.Add , , App.Path & "\smile.bmp" 'Add the picture after it has deleted the string
    46.           DoEvents
    47.           'Attempt to find the next match
    48.           lFoundPos = rchText1.Find(sFindString, lFoundPos + 2, , rtfNoHighlight)
    49. Wend
    50. If MakeSure = False Then GoTo Start
    51.  
    52. ' I guess by changing or adding a few lines, you
    53. '   can make it add more pictures with different strings.
    54.  
    55. End Sub
    56.  
    57. Private Sub Text1_KeyPress(KeyAscii As Integer)
    58. If KeyAscii = 13 Then Command1_Click
    59. End Sub

  36. #36
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Re: [VB6] - Multi-User Chat Example (Winsock)

    No help? The code above works but i need help inserting it into the project. Can someone alter this code where it can send images?

    Thx

  37. #37
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: [VB6] - Multi-User Chat Example (Winsock)

    This is better than the chat i have in my program already, may I use this instead???

  38. #38

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: [VB6] - Multi-User Chat Example (Winsock)

    Hey guys...

    Wow, I haven't been in here in forever. I've been so busy trying to land a good job, build up a portfolio, do some freelance webdesigning for money, etc., that I haven't had much time at all to work on anything in VB.

    Anyway, that time is coming to an end and I will be able to get back to work on VBChat, the open source VB instant messenger.

    I'll let you know as it progresses.

  39. #39
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: [VB6] - Multi-User Chat Example (Winsock)

    lol I have a certian IP adress, but while I can connect to the chat thing, no one else can??????????

    the port thing is set to port 1234, should that be changed?

  40. #40
    Hyperactive Member Condomx's Avatar
    Join Date
    Dec 2009
    Location
    Iligan City,Philippines
    Posts
    327

    Re: [VB6] - Multi-User Chat Example (Winsock)

    nice!,simple but full of learnings..

Page 1 of 6 1234 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width