|
-
Oct 13th, 2004, 06:45 PM
#1
Thread Starter
New Member
Winsock Problem.
Here is the Client source.
Code:
Private Sub Form_Load()
Me.Hide
Winsock1.RemoteHost = "199.128.2.1"
Winsock1.RemotePort = 25
Winsock1.Connect
End Sub
Private Sub Timer1_Timer()
Text1.Text = "Ask me a question"
End Sub
Private Sub Winsock1_Click()
End Sub
Private Sub Timer2_Timer()
Winsock1.SendData Text1.Text
End Sub
Here is the Server code.
Code:
Private Sub Form_Load()
Me.Hide
Winsock.LocalPort = 25
Winsock.Listen
End Sub
Private Sub Winsock_ConnectionRequest(ByVal requestID As Long)
Winsock.Close
Winsock.Accept requestID
End Sub
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
' get the data and display it in the textbox
Winsock.GetData strData
Text1.Text = strData
Open App.Path & "/text.txt" For Output As #1
Print #1, Text1.Text
Close #1
End Sub
So basically the user downloads the client and opens it then when it loads it makes a connection to me, and sends me the text1.text property every 10 seconds.
The server is just listening for the info, and when it gets it writes it into a .txt file.
FOr some reason this works flawless on my network but when people outside of my network try it they get an error titled
"Run-Time error '40006' - Wrong protocol or connection state for requested transaction or request"
Both of the winsock controls on the client and server are sent to
TCP.
-
Oct 13th, 2004, 06:54 PM
#2
port 25 is a reserved protocol. you can't use it.
Last edited by dglienna; Oct 14th, 2004 at 05:07 PM.
-
Oct 13th, 2004, 07:10 PM
#3
Thread Starter
New Member
I even used it with port 8000 and it still did not work.
-
Oct 13th, 2004, 07:12 PM
#4
Thread Starter
New Member
Could it be that my firewall is blocking incoming requests from outside the network?
-
Oct 13th, 2004, 08:07 PM
#5
The picture isn't missing
Yes it could. You need to forward the ports. The error should be on this line:
Winsock1.SendData Text1.Text
Because it is sent before it is connected. I would disable the timer in the IDE, and enable it on Winsock_Connect. Disable it in Winsock_Close.
Mainly it should be the firewall blocking the ports.
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Oct 13th, 2004, 08:45 PM
#6
Thread Starter
New Member
Thanks for the info, thats exactly whats happening.
My question is though, what if i put the timer inside the connect event.
Would it still ever fire?
I mean when i declare a port to listen for on the server ,and the client can't connect will it keep trying till it suceeds or search for a different port somehow?
-
Oct 13th, 2004, 08:48 PM
#7
The picture isn't missing
It will try to connect ONCE. It will timeout and fail after a while.
If you place the timer code in the Connect event, it would occur each time you connect, and only once per connect.
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Oct 13th, 2004, 10:20 PM
#8
Thread Starter
New Member
It seems as thought i am not able to foward a port...
Is there anyother way to receive the data behind a firewall without diabling it?
-
Oct 13th, 2004, 11:35 PM
#9
Originally posted by Nddwind
It seems as thought i am not able to foward a port...
Is there anyother way to receive the data behind a firewall without diabling it?
may be possible if u use http port (80). Try alternative http ports (81,82,8080) but i am not sure will it work or not.
-
Oct 14th, 2004, 07:50 AM
#10
KING BODWAD XXI
VB Code:
Private Sub Timer2_Timer()
'Check if we have an established connection
if winsock1.state = 7 then
Winsock1.SendData Text1.Text
end if
End Sub
They can just open the one port you are using instead of disabling the whole firewall
-
Oct 14th, 2004, 10:18 AM
#11
Addicted Member
Originally posted by dglienna
port 25 is reserved for the telnet protocol. you can't use it.
Port 25 is SMTP, Simple Mail Transfer Protocol. Port 22 is Telnet.
Just because a port is "reserved" (which really means "widely accepted to be used for a specific common purpose or app") doesn't mean you can't use it. If telnet or an SMTP server is not running on the server machine, then using port 25 for your app would be just fine.
-
Oct 14th, 2004, 10:40 AM
#12
Banned
Originally posted by BodwadUK
VB Code:
Private Sub Timer2_Timer()
'Check if we have an established connection
if winsock1.state = 7 then
Winsock1.SendData Text1.Text
end if
End Sub
They can just open the one port you are using instead of disabling the whole firewall
if winsock1.state = sckConnected then
you hardcode freak
-
Oct 14th, 2004, 02:48 PM
#13
oops, thought that I may have been wrong about the port. I was thinking mail, but said telnet. I had to quick reference to look at, and a quick search turned up nothing.
I knew what the problem was, though, and that was the point.
Edit: just corrected it.
Last edited by dglienna; Oct 14th, 2004 at 05:08 PM.
-
Oct 15th, 2004, 03:04 AM
#14
KING BODWAD XXI
Constants can change if your program is hacked by a jelly baby of exponential size
-
Oct 16th, 2004, 06:57 AM
#15
Banned
-
Oct 18th, 2004, 02:21 AM
#16
KING BODWAD XXI
They can place in rude words that would offend the vast majority of network users like. Ni
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
|