|
-
Apr 4th, 2001, 04:23 PM
#1
Hi,
Just started trying to make a simple messinging program in VB using winsock.. i really can't see what is going wrong!.. anyway.. i'll post up the code of the send program and the receive program.. maybe its really obvious hah i just don't see it!
THE SENDER
Option Explicit
Dim strOutgoing As String
Dim strIP As String
Private Sub cmdSendMsg_Click()
strIP = txtHostName.Text
strOutgoing = txtMessage.Text
winsock.RemoteHost = strIP
winsock.RemotePort = 201
winsock.Connect
Do Until winsock.State = sckConnected
DoEvents: DoEvents: DoEvents: DoEvents
If winsock.State = sckError Then
MsgBox "Problem connecting!"
Exit Sub
End If
Loop
winsock.SendData (strOutgoing)
winsock.Close
End Sub
THE RECEIVER
Private Sub Form_Load()
winsock.LocalPort = 201
winsock.Listen
End Sub
Private Sub winsock_ConnectionRequest(ByVal requestID As Long)
If winsock.State <> sckClosed Then winsock.Close
winsock.Accept requestID
End Sub
Private Sub winsock_DataArrival(ByVal bytesTotal As Long)
Dim strIncoming As String
winsock.GetData strIncoming
lblMessage.Caption = strIncoming
End Sub
Thanks for your help, i always get my error msg "Can't connect" so obviously something goes wrong :-(
-
Apr 4th, 2001, 04:41 PM
#2
Banned
Are the Sender program and receiver program in the same computer? If yes I think that's the problem.
-
Apr 4th, 2001, 04:44 PM
#3
yep
well yes they are.. but they should still work using 127.0.0.1 shouldn't they?
-
Apr 4th, 2001, 06:45 PM
#4
Banned
Well that I don't know. You would better try using two computers. I have downloaded once a vb project (here in vb world) that with a small change it would work with the same computer, but with me, it didn't work.
It's rather confusing the stuff of dynamical IPs. Thanks to a vb project, the IP of my dad's computer is 127.0.0.1 ... 
Find a friend who is willing to try it with you. I think it's the best you can do
-
Apr 5th, 2001, 09:01 AM
#5
Frenzied Member
Re: yep
Originally posted by nzer
well yes they are.. but they should still work using 127.0.0.1 shouldn't they?
IP address 127.0.0.1 is called the loopback address. A loopback address is an address that tells the computer to test its own basic network setup. Data is passed within the local TCP/IP stack.
My first question would be "Is the TCP/IP protocol installed on your PC"? If so, you can use 127.0.0.1 to test both the client and the server on your PC. I have done that my self even though I have static IP addresses on my PCs.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|