Results 1 to 16 of 16

Thread: Winsock Problem.

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    13

    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.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    port 25 is a reserved protocol. you can't use it.
    Last edited by dglienna; Oct 14th, 2004 at 05:07 PM.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    13
    I even used it with port 8000 and it still did not work.

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    13
    Could it be that my firewall is blocking incoming requests from outside the network?

  5. #5
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    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 .

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    13
    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?

  7. #7
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    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 .

  8. #8

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    13
    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?

  9. #9
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424
    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.

  10. #10
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    VB Code:
    1. Private Sub Timer2_Timer()
    2.    'Check if we have an established connection
    3.    if winsock1.state = 7 then
    4.        Winsock1.SendData Text1.Text
    5.    end if
    6.  
    7. End Sub

    They can just open the one port you are using instead of disabling the whole firewall
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  11. #11
    Addicted Member
    Join Date
    Sep 2004
    Location
    Brooklyn
    Posts
    147
    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.

  12. #12
    Originally posted by BodwadUK
    VB Code:
    1. Private Sub Timer2_Timer()
    2.    'Check if we have an established connection
    3.    if winsock1.state = 7 then
    4.        Winsock1.SendData Text1.Text
    5.    end if
    6.  
    7. 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

  13. #13
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    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.

  14. #14
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    Constants can change if your program is hacked by a jelly baby of exponential size
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  15. #15
    and?

  16. #16
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    They can place in rude words that would offend the vast majority of network users like. Ni
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width