|
-
Feb 27th, 2001, 12:10 PM
#1
Thread Starter
Member
why won't this code work?
the sending App:
On Error Resume Next
Winsock1.RemoteHost = txtAddress.Text
Winsock1.RemotePort = 1000
Winsock1.Connect txtAddress.Text, 1000
Do Until Winsock1.State = sckConnected
DoEvents: DoEvents: DoEvents: DoEvents
If Winsock1.State = sckError Then
MsgBox "There was a fatal error!"
Exit Sub
End If
Loop
Winsock1.SendData (txtMessage.Text)
Winsock1.Close
then receiving app:
Private Sub Form_Load()
On Error Resume Next
Winsock1.LocalPort = 1000
Winsock1.Listen
End Sub
Private Sub Form_Unload(Cancel As Integer)
Form3.Hide
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
On Error Resume Next
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim strIncoming As String
Winsock1.GetData strIncoming
textbox1.Text = textbox1.Text & vbCrLf & strIncoming
End Sub
Wisdom is supreme, therefore get wisdom,
though it costs all you have, get understanding.
Proverbs 4:7
-
Feb 27th, 2001, 12:13 PM
#2
Retired VBF Adm1nistrator
Instead of using :
Do Until Winsock1.State = sckConnected
Why dont you just use the Connect() Event for the winsock control ?
Also, try this :
Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim strIncoming As String
Winsock1.GetData strIncoming, vbString
'note the above vbString part
textbox1.Text = textbox1.Text & vbCrLf & strIncoming
End Sub
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Feb 27th, 2001, 12:16 PM
#3
Thread Starter
Member
err
Because for some reason it won't connect, I get "Can't connect!" (my own error trapping that means there's an error connecting.
Wisdom is supreme, therefore get wisdom,
though it costs all you have, get understanding.
Proverbs 4:7
-
Feb 27th, 2001, 12:18 PM
#4
Are you getting an error? Or is it just not sending text? Please explain what is happening and what you are doing.
-
Feb 27th, 2001, 12:20 PM
#5
What val;ue are you putting in for txtAddress?
-
Feb 27th, 2001, 12:23 PM
#6
Thread Starter
Member
I am getting the error I put in there for error trapping (see code) and for the IP, i'm putting 127.0.0.1
Wisdom is supreme, therefore get wisdom,
though it costs all you have, get understanding.
Proverbs 4:7
-
Feb 27th, 2001, 12:26 PM
#7
Retired VBF Adm1nistrator
The localhost address doesnt always work, well at least in my experience.
Make sure the Winsock controls are using TCP and not UDP.....
Also, run 'winipcfg', get the IP of your network adapter if you have one, and try using that....
Could you post the project zipped as an attachment ?
- jamie
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Feb 27th, 2001, 12:27 PM
#8
Try taking out the parameters after Connect
Winsock1.Connect txtAddress.Text, 1000
just use Winsock1.Connect
then try again.
Maybe ?!?!
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
|