Results 1 to 23 of 23

Thread: VB IM program

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    163

    VB IM program

    I have a server with email facility like anything@asgsoft.net

    I want to make an instant messenger program for it.

    What program do I use, VB6 Enterprise or VB.net standard

    What serverside script will I need e.g. PHP or ASP

    I am good with PHP but a noob with ASP

    So Can you help to to start from the beggining.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: VB IM program

    There are examples of Chat programs in our CodeBank. Take a look. I'm sure there is something there that will get you started.

  3. #3
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: VB IM program

    Quote Originally Posted by asgsoft
    I have a server with email facility like anything@asgsoft.net

    I want to make an instant messenger program for it.

    What program do I use, VB6 Enterprise or VB.net standard
    Either are more than capable of producing a good IM system, so use which ever you are most proficient with.

    What serverside script will I need e.g. PHP or ASP

    I am good with PHP but a noob with ASP
    Again PHP and ASP will both do the job, since your better with PHP, use that.
    So Can you help to to start from the beggining.
    It depends what level your at, if your a beginner to VB then you should read tutorials from google, and get familiar with the language before starting something huge like this.

    you will need a good understanding of VB/VB.net, and also a good understanding of windows sockets. Sockets are what will make your app connect to other hosts and send/receive data. for VB6 you can use the Winsock control which is really easy to use and learn fast. Find tutorials at www.winsockvb.com

    If using .net sockets are a little harder, there is no winsock control you should read about the Sockets namespace, either that or find a 3rd party class that makes it easier.

    you could also use the winsock API, tutorials at www.winsockvb.com

    finally, there is many IM systems source code available at www.pscode.com,

    good luck!
    Chris

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    163

    Re: VB IM program

    thanks for your great advice, I have decided to use VB6 and PHP.

    I will start with learning Winsock and starting from there

  5. #5
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: VB IM program

    good choice
    Chris

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    163

    Re: VB IM program

    I started on it and everything is fine except one thing. When I stop testing the program VB crashes. I figured it is because I am using winsock control. Is there any way of preventing it?

  7. #7
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: VB IM program

    instead of just terminating the app, you should close the socket
    VB Code:
    1. Winsock1.Close
    i had this problem too
    Chris

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    163

    Re: VB IM program

    so if this is my current code:

    VB Code:
    1. Option Explicit
    2.  
    3.  
    4.  
    5. Private Sub Form_Load()
    6.  
    7.     ' set up the winsock to connect to the local computer
    8.  
    9.     Winsock.RemoteHost = "127.0.0.1"
    10.  
    11.     Winsock.RemotePort = 80
    12.  
    13.     Winsock.Connect
    14.  
    15. End Sub
    16.  
    17.  
    18.  
    19. Private Sub cmdSend_Click()
    20.  
    21.     ' send the data thats in the text box and
    22.  
    23.     ' clear it to prepare for the next chat message
    24.  
    25.     Winsock.SendData txtChat.Text
    26.  
    27.     DoEvents
    28.  
    29.     txtMain.Text = txtMain.Text & vbCrLf & txtChat.Text
    30.  
    31.     txtChat.Text = ""
    32.  
    33. End Sub
    34.  
    35.  
    36.  
    37. Private Sub Winsock_Connect()
    38.  
    39.     ' we are connected!
    40.  
    41.     MsgBox "Connected"
    42.  
    43. End Sub
    44.  
    45.  
    46.  
    47. Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
    48.  
    49. Dim strData As String
    50.  
    51.     ' get the data from the socket
    52.  
    53.     Winsock.GetData strData
    54.  
    55.     ' display it in the textbox
    56.  
    57.     txtMain.Text = txtMain.Text & vbCrLf & strData
    58.  
    59.     ' scroll the box down
    60.  
    61.     txtMain.SelStart = Len(txtMain.Text)
    62.  
    63. End Sub
    64.  
    65.  
    66.  
    67. Private Sub Winsock_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    68.  
    69.     ' an error has occured somewhere, so let the user know
    70.  
    71.     MsgBox "Error: " & Description
    72.  
    73.     ' close the socket, ready to go again
    74.  
    75. End Sub

    Where do I add:

    VB Code:
    1. Winsock.Close

  9. #9
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: VB IM program

    try this
    VB Code:
    1. 'Close event
    2. Private Sub Winsock_Close()
    3. 'this event fires when the other computer disconnects
    4.     Winsock.Close
    5.     MsgBox "Connection terminated by remote side"
    6. End Sub
    7. 'Error event
    8. Private Sub Winsock_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    9.     Winsock.Close
    10.     MsgBox "Error: " & Description
    11. End Sub
    12. 'form unload event
    13. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    14. 'This fires when the user tries to unload the form
    15.     Winsock.Close
    16. End Sub
    Dont use the stop button in VB to close ur app, use the X on the form
    Chris

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    163

    Re: VB IM program

    what is the correct port I should you on my domain, i won asgsoft.net and when I tried to use port 80 with my friend it wouldn't send my message to him and i wouldn't receive his.

    Do i need any server side scripts at the moment?

  11. #11
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: VB IM program

    when you use winsock you have one app which is the server (listening) and one app which is the client (connecting), so the server needs to listen on the same port that the client connects to, it can be any port as long as its not in use and exists, there is approx 65,000 ports. you need to connect to the server app not necessarily your domain name
    Chris

  12. #12
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: VB IM program

    Also the computer that's listening can't be behind a firewall or a router unless the firewall allows incoming connections on that port or the router forwards that port to that computer.

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    163

    Re: VB IM program

    it still crashes.

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    163

    Re: VB IM program

    how do I know which port to use?

  15. #15
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: VB IM program

    use any port thats not in use, as long as the server listens on that port and the client connects on that port
    Chris

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    163

    Re: VB IM program

    I am confused. I chose to use port 180 I can connect to it and send to it but how do i make it listen?

  17. #17
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: VB IM program

    you need 1 app to listen, and seperate app to connect, it explains it in the tutorials I think @ winsockvb.com and vbip.com

    VB Code:
    1. 'this will be the app that accepts the connection
    2. sckServer.Close
    3. sckServer.LocalPort = 180
    4. sckServer.Listen

    VB Code:
    1. 'this will be the app which makes a connection attempt
    2. sckClient.Close
    3. sckClient.Connect "127.0.0.1", 180

    you need code in the dataArrival and connection request events also, which is explained in the tuts
    Chris

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    163

    Re: VB IM program

    is there a way of putting them all into one application?

    Like all other programs

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    163

    Re: VB IM program

    Could you please kindly look at what I have at the moment because it doesn't seem to work.

    I only have the project files, no EXE.

    That will be extreemly apriciated
    Attached Files Attached Files

  20. #20
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: VB IM program

    both apps are servers theres no client, so i've fixed it so one is a client, one server. you can make a single app be both client or server, but its better to start having them seperate so you understand how it works before you make it more advanced
    Attached Files Attached Files
    Chris

  21. #21

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    163

    Re: VB IM program

    I had to do some small fixes, otherwise its great. I will try to make it work with a mail server i am working on at the moment

  22. #22

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    163

    Re: VB IM program

    At the moment it works fine but only on one computer.

    How can I chat using it with other people who are online?

  23. #23
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: VB IM program

    you can compile the client into a exe file and send them it, so you would run the server on your computer, and have your friend run the client on his computer, change the IP address in the code (127.0.0.1) to your real IP so they can connect, find your ip at yourip.com. Or you could have a textbox on the form so they can type the IP in.

    if they get a dependency error when they run the exe it is most likely that they dont have the winsock file, which is mswinsck.ocx located in Windows\System32

    one more thing if you use a router to connect to the internet you need to forward the port 180 on your router to your LAN IP, take a look in your instruction manual for how to forward the port
    Chris

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