Unable to make a online chat.
Hi, i've followed Vb6.us tutorial for how to make a simple chat.
Now i've opened port 1336-1336, and checked my IP from Myip.se.
If i connect to my chat with local settings, 127.0.0.1 as IP, it connects.
If i connect to my chat with online settings, xxx.xxx.x. And port 1337, it wont connect.
Any suggestions ?
Re: Unable to make a online chat.
Don't if my problem relates to yours. I was trying to open a local file on my pc from my website, but could not, because i have 2 ip settings one on my pc and one after my router. I was trying to setup my own live chat.
I finally just used a free one: http://www.livezilla.net/downloads/
Re: Unable to make a online chat.
Quote:
Originally Posted by macbrutal
Hi, i've followed Vb6.us tutorial for how to make a simple chat.
Now i've opened port 1336-1336, and checked my IP from Myip.se.
If i connect to my chat with local settings, 127.0.0.1 as IP, it connects.
If i connect to my chat with online settings, xxx.xxx.x. And port 1337, it wont connect.
Any suggestions ?
You would get better help if you just simply posted the code you are using.
Re: Unable to make a online chat.
I made a chat app awhile ago fortunately some of my post about it remain. You might find them useful!
http://www.vbforums.com/showthread.php?t=234908
Edit:
Here is a basic example I did years ago:
http://www.vbforums.com/showthread.php?t=236973
If you want to enable ftp for your program:
http://www.vbforums.com/showthread.php?t=237913
Re: Unable to make a online chat.
Are you testing on computers connected via Internet?
Re: Unable to make a online chat.
jmsrickland, The code is very very VERY simple.
Client:
vb Code:
Private Sub CmdConnect_Click()
sockmain.RemoteHost = txthost.Text
sockmain.RemotePort = txtport.Text
sockmain.Connect
End Sub
Private Sub CmdSend_Click()
sockmain.SendData txtsend.Text
End Sub
Private Sub Form_Load()
Form2.Show
End Sub
Private Sub sockmain_DataArrival(ByVal bytesTotal As Long)
Dim strdata As String
sockmain.GetData strdata, vbString
txtstatus.Text = txtstatus.Text & _
strdata & vbCrLf
End Sub
--
Server:
vb Code:
Private Sub CmdListen_Click()
sockmain.LocalPort = txtport.Text
sockmain.Listen
End Sub
Private Sub CmdSend_Click()
sockmain.SendData txtsend.Text
End Sub
Private Sub Form_Load()
End Sub
Private Sub sockmain_ConnectionRequest(ByVal requestID As Long)
If sockmain.State <> sckClosed Then
sockmain.Close
End If
sockmain.Accept requestID
txtstatus.Text = txtstatus.Text & _
"Accepted connection from: " & _
sockmain.RemoteHostIP & vbCrLf
End Sub
Private Sub sockmain_DataArrival(ByVal bytesTotal As Long)
Dim strdata As String
sockmain.GetData strdata, vbString
txtstatus.Text = txtstatus.Text & _
strdata & vbCrLf
End Sub
Re: Unable to make a online chat.
Nightwalker, thanks for the codes. but it's not the coding that's wrong i guess, it's the ports or something. They ARE open and enabled.
It might be that, when i installed VB6 it found the Winsock corrupt and i needed to fix that by downloading microsoft fix something, which made it work.
dee-u, I just simply starts from my computer and type the things in, everything is in the same computer.
Connected via internet, yes... if i understand that right.
Re: Unable to make a online chat.
Quote:
Originally Posted by macbrutal
Nightwalker, thanks for the codes. but it's not the coding that's wrong i guess, it's the ports or something. They ARE open and enabled.
It might be that, when i installed VB6 it found the Winsock corrupt and i needed to fix that by downloading microsoft fix something, which made it work.
In your original post you said that you enabled ports 1336 - 1336.
Quote:
Now i've opened port 1336-1336, and checked my IP from Myip.se.
I'm guessing that is a typo and you mean to type 1336 - 1337 but port 1337 is the port your are listening on?
Re: Unable to make a online chat.
Incorrect, my router says port 0 - 0, so i put 1337 - 1337. just for opening case. and i've tried "Both UDP and TCP" still nothing..
Correct, im listening on port 1337
Re: Unable to make a online chat.
Quote:
Originally Posted by macbrutal
Hi, i've followed Vb6.us tutorial for how to make a simple chat.
Now i've opened port 1336-1336, and checked my IP from Myip.se.
If i connect to my chat with local settings, 127.0.0.1 as IP, it connects.
If i connect to my chat with online settings, xxx.xxx.x. And port 1337, it wont connect.
Any suggestions ?
When you get your IP from Myip.se (I'm guessing that's an online website that tells you what your IP is) you are getting your external IP; the IP that is accessable from the outside world (as long as you allow the outside world to connect to you) and that is not your internal IP which is the IP you need to use if you are running both Client and Server on the same PC.
So, when you run your Client/Server chat on the same PC and you use 127.0.0.1 and the client uses the same Port Number that the server is on then it works.
When you connect to your server using xxx.xxx.x (I'm guessing this is the IP you got from Myip.se) from your client on the same PC it wont work because that IP is not your internal IP.
For testing purposes use your internal IP or the loop-back IP of 127.0.0.1. When you are ready to use your chat accross two different PCs (yours and your friend's PC) then you use your external IP.
Re: Unable to make a online chat.
Jmsrickland, my friend who tried my first applications were able to connect as the same way im trying, and he did exact same way.
I've send my newest application to him, and it doesn't work.
So im asking again, is it possible that my Wnsck.ocx is corrupt, because it was from installation, but later on were fixed.
Re: Unable to make a online chat.
Yes, it is possible.
Put a _Error event in your code and see if anything happend there.
Re: Unable to make a online chat.
I've done that, and i get socket timed out
1 Attachment(s)
Re: Unable to make a online chat.
Quote:
Originally Posted by macbrutal
Jmsrickland, my friend who tried my first applications were able to connect as the same way im trying, and he did exact same way.
I've send my newest application to him, and it doesn't work.
So im asking again, is it possible that my Wnsck.ocx is corrupt, because it was from installation, but later on were fixed.
I have attached my mswinsck.ocx, if you want to try another one
Re: Unable to make a online chat.
Quote:
Originally Posted by macbrutal
I've done that, and i get socket timed out
Well, I really doubt that you have a corrupted Winsock control. You are doing something that you are not telling us exactly what it is.
You say that you and your friend were successful before but now on you newer version he cannot connect to you. Have you tried the other way around; you connect to him (he is the server, you are the client). Make sure the server is up and listening before you try to connect. BTW: how does your friend know when to connect? Are you communicating over the phone and you tell him that your server is up and listening and what your IP is and the Port number? Could it be a firewall problem (his side or your side)?
Re: Unable to make a online chat.
Jmsrickland, I will tell you exact.
I've Vb6 at my fathers house, works perfect.
Now I'm at my moms house, newly installed but got an error when i were about to insert a WnSck.ocx to my program, but microsoft had a program which fixed that problem.
now, Me and my friend we're on ventrilo, he was the server because i don't have access to router settings at my fathers house.
Now, He didn't have to open firewall and stuff, only ports. which i had too.
Just sounds so strange, that it won't work :s
Re: Unable to make a online chat.
isnoend07, i tried your idea too, no progress :/
Re: Unable to make a online chat.
OK, I am going to take your word for it that
1) The Server is up and running and waiting in the Listening Mode
2) The Client's RemoteHost IP is exactly the external IP address of the Server
3) The Client's RemotePort is exactly the same as the Server's Port number
4) Then the Client tries to connect to the Server and all that happens is you get a timeout error.
Did you even try isnoend07's example to see if that works? However, if he didn't include his Winsock.ocx then even that probably won't work.
Rather than try and to fix that Winsock error with Microsoft whatever why don't you just go get another Winsock.ocx from the Intenet and use it.
Re: Unable to make a online chat.
Quote:
Originally Posted by macbrutal
Jmsrickland, I will tell you exact.
I've Vb6 at my fathers house, works perfect.
I noticed in your code you have sockmain listening after you click the command button. I suggest putting it in the form load event:
Code:
Private Sub Form_Load()
sockmain.LocalPort = 1337
sockmain.Listen
End Sub
Also your code to close the connection is formatted incorrectly.
Try:
Code:
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If sockmain.State <> closed Then sockmain.Close
sockmain.Accept requestID
End Sub
Re: Unable to make a online chat.
Actually, you don't even need to test for the Winsock state in the _ConnectionRequest Event
Code:
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
sockmain.Close
sockmain.Accept requestID
End Sub
is all that is needed
Re: Unable to make a online chat.
Quote:
Originally Posted by Nightwalker83
I noticed in your code you have sockmain listening after you click the command button. I suggest putting it in the form load event:
Code:
Private Sub Form_Load()
sockmain.LocalPort = 1337
sockmain.Listen
End Sub
Also your code to close the connection is formatted incorrectly.
Try:
Code:
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If sockmain.State <> closed Then sockmain.Close
sockmain.Accept requestID
End Sub
No, you are incorrect here, Nightwalker
Re: Unable to make a online chat.
Quote:
Originally Posted by jmsrickland
No, you are incorrect here, Nightwalker
Yeah, I saw your code without:
Code:
If sockmain.State <> closed Then sockmain.Close
Your way is quicker! I must admit I am not a computer programmer and it has been years since I last created a program in Visual Basic.
Re: Unable to make a online chat.
Quote:
Originally Posted by macbrutal
dee-u, I just simply starts from my computer and type the things in, everything is in the same computer.
Connected via internet, yes... if i understand that right.
I would suggest that you need to test it in an environment where the computers are connected via internet and not just one computer.