|
-
Aug 24th, 2000, 12:22 PM
#1
Thread Starter
Frenzied Member
I know this is properly the third time asking the same question,
but I can't get my WinSock program to work!!!
The program must send text strings between to computers...
Computer no.1 has a static IP set to: 1.0.0.1 (When I call the following command: Winsock1.LocalIP, it returns:
246.132.155.221! Could this be the error??)
Computer no.2 also has a static IP which is 1.0.0.2
Ok....here is the problem: When I'm trying to connect to 1.0.0.2 from my app, the WinSock state is 6, but it must be 7.....I
can't get it go 7!!!!
Here is the code for the client (1.0.0.1)
Code:
Private Sub cmdConnect_Click()
Winsock1.Connect txtIP.Text, 1234
Debug.Print Winsock1.State
End Sub
Private Sub cmdSend_Click()
Winsock1.SendData txtData.Text
End Sub
Private Sub Winsock1_Connect()
Me.Caption = "Connected"
End Sub
Here is the code for the server (1.0.0.2)
Code:
Private Sub cmdListen_Click()
Winsock1.LocalPort = 1234
Winsock1.Listen
End Sub
Private Sub Form_Load()
Winsock1.LocalPort = 1234
Winsock1.Listen
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Winsock1.GetData strData, vbString
txtData.Text = strData
End Sub
Could some of you please tell me what I'm doing wrong?????
Thanks in advance!
-
Aug 25th, 2000, 08:56 AM
#2
Fanatic Member
Originally posted by CyberCarsten
(When I call the following command: Winsock1.LocalIP, it returns:
246.132.155.221! Could this be the error??)
Where does that IP address come from? It seems to be some Danish internet address or something.
Have you tried using the LocalHost property and setting its value to the Computer Name to see if the client can connect to the server?
-
Aug 25th, 2000, 09:01 AM
#3
New Member
Is Computer no.1 connected over a dial-in or other means to the internet as well as to your local net?
That's not a BUG, It's a feature!
VB6 Professional Service Pack 3
Windows CE Embedded Visual Tools 3
-
Aug 25th, 2000, 09:22 AM
#4
Fanatic Member
before you accept the connection you must close the winsock
winsock.close
winsock.accept etc
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Aug 25th, 2000, 09:24 AM
#5
Fanatic Member
If thats not the problem make sure the network is working properly ping 1.0.0.1 from 1.0.0.2 or vice versa.
The just try telneting into your app if see if the problem is on the client or the server side
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Aug 25th, 2000, 09:49 AM
#6
Thread Starter
Frenzied Member
There are connection between the two computers...
To HaxSoft:
The IP came from my installer CD, but I have corrected the error! : o )
-
Aug 25th, 2000, 02:02 PM
#7
Fanatic Member
Carsten:
Have you tried reversing the setup, that is running the server application on computer no. 1 and the client app on computer no. 2?
If that works as expected, then you have at least verified that the code is OK and the problem might be the network. If it does not work, then it might be the code that needs further examination.
Held og lykke <<-- I know you know what that means, although some other programmers on here may not understand.
-
Aug 25th, 2000, 02:07 PM
#8
Thread Starter
Frenzied Member
He he! I understand perfectly! : o )
Jeg har haft det til at virke, men nu har jeg bygget programmet lidt om og NU virker det slet ikke!!!!
Her er kilde koden:
(Programmet er både client og server)
Code:
Private Sub cmdSend_Click()
sckConnect.SendData Client.txtNick.Text & " >" & SendMsg.Text
Message.AddItem Client.txtNick.Text & " >" & SendMsg.Text
End Sub
Private Sub Form_Load()
frmChat.Caption = "CyberCarsten's LAN Chat - Client - [Server:" & Client.txtServerIP.Text & " - Nick: " & Client.txtNick.Text & "]"
sckConnect.RemotePort = Client.txtServerIP.Text
sckConnect.LocalPort = Client.txtLocalPort
sckConnect.Connect Client.txtServerIP.Text, Client.txtPort.Text
End Sub
Private Sub sckConnect_Connect()
Message.AddItem "Connected to" & " " & Client.txtServerIP.Text
End Sub
Private Sub sckConnect_ConnectionRequest(ByVal requestID As Long)
' Check if the control's State is closed. If not,
' close the connection before accepting the new
' connection.
If sckConnect.State <> sckClosed Then _
sckConnect.Close
' Accept the request with the requestID
' parameter.
sckConnect.Accept requestID
End Sub
Private Sub sckConnect_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
sckConnect.GetData strData, vbString
Message.AddItem strData
End Sub
To all others....sorry if you don't understand what I'm writting, but I found out that HaxSoft is Danish!! So why not write in danish? : o )
[Edited by CyberCarsten on 08-25-2000 at 03:09 PM]
-
Aug 29th, 2000, 05:06 AM
#9
Fanatic Member
Hmm, [keeping this English... just in case someone else is interested] 
Anyway, in the following code, I think you made a typing mistake. It seems to me that you are setting the RemotePort to the server's IP address instead of the remote port. Also, you are using txtPort when you make the connection. Are these things supposed to be this way?
Code:
Private Sub Form_Load()
frmChat.Caption = "CyberCarsten's LAN Chat - Client - [Server:" & _
Client.txtServerIP.Text & " - Nick: " & _
Client.txtNick.Text & "]"
sckConnect.RemotePort = Client.txtServerIP.Text
sckConnect.LocalPort = Client.txtLocalPort
sckConnect.Connect Client.txtServerIP.Text, Client.txtPort.Text
End Sub
In addition, from the code you submitted, I can't see where you instruct the server to go into [i]Listening[/b] state. This is necessary for the server to detect incoming connection requests.
I wrote a chat program some time ago. That program was both a client and a server, just like yours. My little program is not very fancy, but it works well. I just don't know where all the code is, but I will find it and mail it to you, if we don't find a solution to the problem pretty soon.
-
Aug 29th, 2000, 11:11 AM
#10
Thread Starter
Frenzied Member
Ok! Thank you very much! : o)
-
Aug 29th, 2000, 02:15 PM
#11
Thread Starter
Frenzied Member
Now I get the following error when I try to invoke the Listen command:
the operation is completed. No blocking operations is in progress
!!!!!
-
Aug 29th, 2000, 02:53 PM
#12
Fanatic Member
Hey, CyberCarsten
Check your email ... with any luck, the app should be there now. I had some problems sending it so let me know if it doesn't work.
If you have any need for any of my code, you can use it ... it is such a small and unfinished program, so it's FREEWARE, hahaha.
***UPDATE***
Had to go back in and edit this message because I forgot to say what I really wanted, haha.
I meant to say that I don't know that error. Anyone else got a clue?
[Edited by HaxSoft on 08-29-2000 at 03:57 PM]
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
|